Can "samtools depth" calculate the depth of inserted bases?
1
0
Entering edit mode
9.7 years ago
Yuu ▴ 10

I have PE125 sequence data and want to calculate the average read length of my reads.

  • average length = total yield base/total reads
  • total yield base = samtools depth -q 0 -Q 0 my.bam | awk '{total+=\$3};END{print total}'
  • total reads also from bam file

The result show the average length of my reads is little smaller than 125, is this because that "samtools depth" can't calculate the inserted base?

samtools-depth • 3.1k views
ADD COMMENT
1
Entering edit mode
9.7 years ago

If you just want to see average read length, this might help you

samtools view <in.bam> | awk '{ sum_length += length($10) } END { print sum_length/NR }'

If you are looking at insert length, Picard's CollectInsertSizeMetrics.jar might help you.

ADD COMMENT
0
Entering edit mode

Thanks for your kind answer, I try your method to calculate the average length (result is 124.946, when I use samtools depth the result is 124.31), but it also not 125.What could cause this? And I also want to know if samtools depth can't calculate the inserted base?

Add: thanks geek_y, yes, we should consider clipping reads, it's the reason

ADD REPLY
0
Entering edit mode

You should take care of soft-clipping and hard-clipping.

ADD REPLY

Login before adding your answer.

Traffic: 1722 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6