Reference Code backup Executable files
Converts feature records in BEDPE format to BAM format
bedtools bedpetobam [OPTIONS] -i <bed/gff/vcf> -g <genome>
This tool is part of the bedtools
suite.
fetchChromSizes
.bedtools
versions before 2.30.0 may produce truncated bam files, if you want to use this function, please upgrade to bedtools v2.30.0 or newer.bedpeToBam
is equivalent to bedtools bedpetobam
.Assume you have feature records in a bedpe file (test.bedpe):
$ cat test.bedpe chr1 100 200 chr5 5000 5100 reads1 30 + - chr9 1000 5000 chr9 3000 3800 reads2 100 - -
And you have a chromosome size file (hg38.chromsizes) dumped by fetchChromSizes
$ head hg38.chromsizes chr1 248956422 chr2 242193529 chr3 198295559 chr4 190214555 chr5 181538259 chr6 170805979 chr7 159345973 chrX 156040895 chr8 145138636 chr9 138394717
Then you can convert these records to bam format with bedtools bedpetobam:
$ bedtools bedpetobam-i test.bedpe
-g hg38.chromsizes
> converted.bam
You can check the content in converted.bam with samtools view
:
$ samtools view converted.bam reads1 99 chr1 101 255 100M = 5001 4900 * * reads1 147 chr1 5001 255 100M = 101 4900 * * reads2 113 chr9 1001 255 4000M = 3001 2000 * * reads2 177 chr9 3001 255 800M = 1001 2000 * *