This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Count 0, 5, 20 covered sites in bam

Hello,

I wonder how to use a bam file to learn how many sites are not covered at all, how many are covered >=5 times and 20 times. We got such stats from our sequencing company, but want to see we can do it ourselves as well.

Thank you very much.

wgs bam

Are you looking to get the stats at individual base level or a interval window?

Thank you for the comment @genomax, I am looking at individual base level.

2 answers

samtools depth -a in.bam | awk '{D=int($3);if(D<5) {D=0;} else if(D<20) {D=5;} else D=20; a[D]++;} END {for(x in a) printf("%s\t%d\n",x,a[x]);}'

5   14484
20  51
0   3771

Thanks for the help! Appreciate it.

You can get the relevant percentage of the genome with plotCoverage, though picard has some similar tools.

Thank you very much!

Log in to answer this question.