<p>Hey all :]</p>

<p>I use samtools&#39;s depth, and occasionally samtool&#39;s pileup commands to calculate coverage of my reads to the genome before binning for coverage. I&#39;m pretty sure everyone else does too ;)</p>

<p>One very common problem is that people find &quot;samtools depth&quot; and &quot;samtools mpileup&quot; don&#39;t match up - and it&#39;s commonly attributed to filtering poor quality reads, duplicates, etc (mpileup doing more filtering).</p>

<p>But there&#39;s a ton of other questions I just can&#39;t get the answers too from the sametools docs, namely:</p>

<p>Does depth/pileup count the region between a paired reads, or just the reads themselves?<br />
Does samtools depth/pileup count singletons in paired end sequencing? Does it extrapolate based on average read length to fillout the whole fragment?<br />
If a read maps to multiple locations, is it counted multiple times?</p>

<p>I&#39;m working with ChIP-Seq data, so i might have to correct for peak-shift. What do you guys think?<br />
<br />
Thanks! :)</p>

<p>There comes a time in every bioinformatician&#39;s life when he/she needs to just read the source code. This is one of those times.</p>

<p>So, depth actually uses pileup internally, just to confuse things a bit more. Depth does not count regions spliced over (i.e., covered by an N operator) or between reads in a pair, which is good because what&#39;s actually going on there would be undefined. I don&#39;t think that pileup counts regions between reads, though I guess I&#39;d have to look to be 100% certain.</p>

<p>Neither tool cares whether a read is a singleton or a part of a pair unless you tell them to filter according to that. Samtools is a pretty general program, so it won&#39;t do ChIP-seq specific things like extrapolating bounds based on average template length.</p>

<p>In general, you&#39;ll need to start going through the code to get answers to questions like these.</p>
