bedtools2 icon indicating copy to clipboard operation
bedtools2 copied to clipboard

bedtools genomecov and non-primary alignments

Open awgymer opened this issue 2 years ago • 2 comments

Does genomecov use non-primary alignments (secondary/supplementary) from the BAM in it's calculations? If so is there any in-built way to exclude them?

awgymer avatar Aug 21 '23 15:08 awgymer

I've just come across this same query, and, from what I can tell, genomecov does use non-primary alignments. To figure this out, I compared it to calculations from mosdepth.

# 1. bedtools genomecov
bedtools genomecov -bga -ibam input.bam > bedtools.depth.tsv

# 2. mosdepth defaults: excluding non-primary, QC fail, unmapped reads, and duplicates = bitwise flag 1796
mosdepth default input.bam 

# 3. mosdepth: excluding QC fail, unmapped reads, and duplicates = bitwise flag 1540
mosdepth -F 1540 flag1540 input.bam

The results of (1) and (3) were identical.

charlesfoster avatar Aug 29 '23 00:08 charlesfoster

Thank you for doing the work I didn't! Do you have any thoughts on the best way to exclude non-primary reads when running genomecov?

Pre-filter with samtools view?

awgymer avatar Aug 29 '23 11:08 awgymer