I have used the samtools coverage function to compute mean depth of coverage for a bam file, and the samtools depth function in conjunction with cat to determine the maximum and minimum depth of coverage values for this same bam. Oddly, the maximum depth of coverage value from the txt created using samtools depth is a smaller value than the mean depth of coverage given by samtools coverage.
This is the code I am applying to the BAM file:
samtools coverage 3_sorted.bam
This returns a value of 15,177 as the mean depth of coverage.
samtools depth 3_sorted.bam -o 3depth.txt
cat 3depth.txt | sort -nk3,3 | head -1
This returns a value of 8040 as the maximum depth of coverage (maximum value in the coverage column of the txt file)
I am hoping someone can point out the mistake in my code, or can explain why the max depth value is smaller than the average (mathematically impossible). Thanks!
Isn't mean depth 15.177 instead of 15177? That number seems absolutely enormous...
Hi Raphael, I belive 15177 is correct. When I run
the result is:
This is huge. Just to know, what interest do you have in getting such a sequencing depth?
Regarding your first question, my guess is that
samtools depth
does not provide you the depth of all positions. Try the-aa
option.