bed 文件格式转换为bam文件利器
bedToBam [OPTIONS] -i <BED/GFF/VCF> -g <GENOME> > <BAM>
#示例文件: rmsk.hg18.chr21.bed
$ more rmsk.hg18.chr21.bed
chr21 9719768 9721892 ALR/Alpha 1004 +
chr21 9721905 9725582 ALR/Alpha 1010 +
chr21 9725582 9725977 L1PA3 3288 +
chr21 9726021 9729309 ALR/Alpha 1051 +
chr21 9729320 9729809 L1PA3 3897 -
#构建 GENOME文件
- 方法1
#hg18
$ mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e "select chrom, size from hg18.chromInfo" >hg18.genome
$ head hg18.genome
chrom size
chr1 247249719
chr1_random 1663265
chr10 135374737
chr10_random 113275
chr11 134452384
chr11_random 215294
chr12 132349534
chr13 114142980
chr13_random 186858
- 方法2
$ wget http://hgdownload.cse.ucsc.edu/goldenPath/hg18/bigZips/chromFa.tar.gz
$ tar zvfx chromFa.tar.gz
$ cat *.fa > hg18.fa
$ rm chr*.fa
$ samtools faidx hg18.fa
$ cut -f1,2 hg18.fa.fai >hg18.genome
注
: BEDtools 如果报错:Less than the req'd two fields were encountered in the genome file ;一般是由于 GENOME文件格式存在问题
#bedToBam 将bed文件转换为bam文件;
$ bedToBam -i rmsk.hg18.chr21.n.bed -g hg18.genome > rmsk.hg18.chr21.bam
#参考
BEDTools bedtobam
Biostars Question: error with bedtools slop