# ===============================================================
# Script to generate a random size-matched background regions
# Author: Xianjun
# Date: Jun 3, 2014
# Usage:
# toGenerateRandomRegions.sh input.bed > output.random.bed
# or
# cat input.bed | toGenerateRandomRegions.sh -
# ===============================================================
bedfile=$1
# other possible options can be the genome (e.g. hg19, mm9 etc.) or an inclusion or exclusion regions (e.g. exons)
# download hg.genome
mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e "select chrom, size from hg19.chromInfo" > hg19.genome
cat $bedfile | while read chr start end rest
do
let l=$end-$start;
bedtools random -g hg19.genome -n 1 -l $l
done
My learning notes for R, Unix, Perl, statistics, tools/resources, biology etc. everything about Bioinformatics
Thursday, September 18, 2014
Simple script to generate random size-matched background regions
Here is a simple script I wrote for generating a random background regions with matched size distribution, using bedtools random and a input.bed as background. Not fancy, but works!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment