Category

Genomic Interval Manipulation


Usage

bedtools bedpetobam [OPTIONS] -i <bed/gff/vcf> -g <genome>


Manual

This tool is part of the bedtools suite.

Arguments

  • -i bed/gff/vcf: Feature records in bed/bedpe/gff/vcf format
  • -g genome: genome’s chrom sizes. This can be retrieved with tools like fetchChromSizes.

Options

  • -mapq INT: Set the mappinq quality for the BAM records. Default: 255
  • -ubam: Write uncompressed BAM output. Default writes compressed BAM.

Notes

  • BED files must be at least BED4 to create BAM (needs name field).
  • 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.

Example

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	*	*

File formats this tool works with
BEDPE

Share your experience or ask a question