This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Excluding reads for Coverage Calculation in given regions

Hello,

I have a bam file and I have a bed file with my region of interests. Now I'm interested in the mean coverage for each of these region. That's no problem with picard's CollectHsMetrics and the PER_TARGET_COVERAGE flag.

But now I would like to exclude those reads in coverage calculation that doesn't overlap my target region with a given fraction or at least given bases.

I feel that bedtools might help me here. But I didn't figure out until now how.

Can someone help me?

fin swimmer

bam bedtools coverage

Hello, thanks for your answer. This is what I do now:

  1. Remove all reads from the bam file that doesn't overlap with at least the given fraction

    bedtools intersect -a full.bam -b regions.bed -f 0.75 -wa > restricted.bam

  2. Use the resulted bam file for coverage calculation with my tool if choice.

That works like it should, but I need to iterate twice over the alignment file. So I'm also interessed in faster ways.

fin swimmer

Why don't you calculate your coverage in your bam with you final bed (i mean region of interest ) using bedtools ?

bedtools needs to much memory for calculate the coverage and I'm very low at it. Also I miss the possibilty to ignore reads/bases below a given quality treshold, like in the picard tools. And I'm more satisfied with the output of picard tools.

How does bedtools handle overlapping paired reads in coverage calculation? Are they counted as 1 or 2?

fin swimmer

0 answers

No answers yet.

Log in to answer this question.