text: user180: I am trying to use samtools depth (v1.4) with the -a option and a bed file listing the human chromosomes chr1-chr22, chrX, chrY, and chrM to print out the coverage at every position:
  cat GRCh38.karyo.bed | awk '{print $3}' | datamash sum 1
  3088286401
  
  I would like to know how to run samtools depth so that it produces 3,088,286,401 entries when run against a GRCh38 bam file:
  samtools depth -b $bedfile -a $inputfile
  
  I tried it for a few bam files that were aligned the same way, and I get differing number of entries:
  3087003274
  3087005666
  3087007158
  3087009435
  3087009439
  3087009621
  3087009818
  3087010065
  3087010408
  3087010477
  3087010481
  3087012115
  3087013147
  3087013186
  3087013500
  3087149616
  
  Is there a special flag in samtools depth so that it reports all entries from the bed file?
  If samtools depth is not the best tool for this, what would be the equivalent with sambamba depth base?
  sambamba depth base --min-coverage=0 --regions $bedfile $inputfile
  
  Any other options?
  
  user73: Just replace the -a option with -aa:
  samtools depth -b $bedfile -aa $inputfile
  
  I see that you're using the GRCh38 human reference genome build, which includes alternate scaffolds that represent a wider variety of genomic variation in the human genome. This was quite a substantial change from previous reference genome builds, and many bioinformatics tools still haven't been updated to accept the GRCh38 reference.
  The discrepancy in entry size is probably because there are alternate contigs that are uncovered by the reads that have been mapped. This is expected, but can cause a bit of confusion.
  
  user110: You might try using bedtools genomecov instead. If you provide the -d option, it reports the coverage at every position in the BAM file.
  bedtools genomecov -d -ibam $inputfile > "${inputfile}.genomecov"
  
  You can also provide a BED file if you just want to calculate in the target  region.
  
original_text: 180: <p>I am trying to use <code>samtools depth</code> (v1.4) with the -a option and a bed file listing the human chromosomes chr1-chr22, chrX, chrY, and chrM to print out the coverage at every position:</p>
  
  <pre><code>cat GRCh38.karyo.bed | awk '{print $3}' | datamash sum 1
  3088286401
  </code></pre>
  
  <p>I would like to know how to run <code>samtools depth</code> so that it produces 3,088,286,401 entries when run against a GRCh38 bam file:</p>
  
  <pre><code>samtools depth -b $bedfile -a $inputfile
  </code></pre>
  
  <p>I tried it for a few bam files that were aligned the same way, and I get differing number of entries:</p>
  
  <pre><code>3087003274
  3087005666
  3087007158
  3087009435
  3087009439
  3087009621
  3087009818
  3087010065
  3087010408
  3087010477
  3087010481
  3087012115
  3087013147
  3087013186
  3087013500
  3087149616
  </code></pre>
  
  <p>Is there a special flag in <code>samtools depth</code> so that it reports all entries from the bed file?</p>
  
  <p>If <code>samtools depth</code> is not the best tool for this, what would be the equivalent with <code>sambamba depth base</code>?</p>
  
  <pre><code>sambamba depth base --min-coverage=0 --regions $bedfile $inputfile
  </code></pre>
  
  <p>Any other options?</p>
   73: <p>Just replace the <code>-a</code> option with <code>-aa</code>:</p>
  
  <pre><code>samtools depth -b $bedfile -aa $inputfile
  </code></pre>
  
  <p>I see that you're using the GRCh38 human reference genome build, which includes alternate scaffolds that represent a wider variety of genomic variation in the human genome. This was quite a substantial change from <a href="https://www.quora.com/What-are-the-differences-between-GRCh38-and-GRCh37" rel="nofollow noreferrer">previous reference genome builds</a>, and many bioinformatics tools still haven't been updated to accept the GRCh38 reference.</p>
  
  <p>The discrepancy in entry size is probably because there are alternate contigs that are uncovered by the reads that have been mapped. This is expected, but can cause a bit of confusion.</p>
   110: <p>You might try using <a href="http://bedtools.readthedocs.io/en/latest/content/tools/genomecov.html" rel="noreferrer">bedtools genomecov</a> instead. If you provide the -d option, it reports the coverage at every position in the BAM file.</p>
  
  <pre><code>bedtools genomecov -d -ibam $inputfile &gt; "${inputfile}.genomecov"
  </code></pre>
  
  <p>You can also provide a BED file if you just want to calculate in the target  region.</p>
  