This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to calculate number of positions covered by at least 10 times in bam file?

Hello everyone! I wonder if somebody could recommend how to calculate the number of positions covered by at least 10 times in bam file? To calculate the number of positions covered by at least once in the bam file I used this oneliner:

bedtools genomecov -ibam my_alignment.bam -bg | awk '{ s+=($3-$2) } END { print s }'

But I have no idea how to modify it, so please help!

coverage bam alignment bedtools awk

2 answers

samtools depth in.bam | awk '($3>10)' | wc -l

Thank you, that works well!

A simple if does the trick.

bedtools genomecov -ibam my_alignment.bam -bg | awk '{ if($4 >= 10) s+=($3-$2) } END { print s }' foo

Thanks, id is perfect!!!

Log in to answer this question.