<p>You could use <code>samtools coverage</code> as explained in the <a href="http://www.htslib.org/doc/samtools-coverage.html" rel="nofollow noreferrer">manual</a> of samtoools.</p>
<p>Here is a example which is also described on the manual site.</p>
<pre><code>samtools coverage -r chr1:1M-12M input.bam

#rname  startpos  endpos    numreads  covbases  coverage  meandepth  meanbaseq  meanmapq
chr1    1000000   12000000  528695    1069995   9.72723   3.50281    34.4       55.8
</code></pre>

CC BY-SA 4.0
2021-03-22T16:15:24.913Z
Are you sure that those statistics are the ones that make the most sense for RNASeq?
swbarnes2
CC BY-SA 4.0
2021-03-21T19:23:10.480Z
2021-03-22T19:01:19.597Z
2021-03-22T19:01:19.597Z
Mr_Z
<p>I've used <a href="https://genome.sph.umich.edu/wiki/BamUtil" rel="nofollow noreferrer">https://genome.sph.umich.edu/wiki/BamUtil</a> before. I think this has all the functionality you want and the Devs are responsive which is nice.</p>

CC BY-SA 4.0
2021-03-21T03:45:49.677Z
2021-03-21T03:45:49.677Z
Liam McIntyre
<p>I have a .bam alignment file and a genome reference .fasta file. I am looking for a easy to use tool (that I can reference in a publication) to calculate the percentage coverage of the reference by the alignment and if possible also: average depth of reads that cover the gene, min/max depths. Running plot would be nice but not essential.</p>
<p>I wrote some python code to calculate coverage percent, but I want to reference the tool I use in a paper and dont want to mess with making a git repo and linking to it in the paper just for this simple analysis.</p>

<rna-seq><phylogenetics>
Calculate genome coverage and depth from alignment
# Calculate genome coverage and depth from alignment

(Asked by: username_0 on 2021-03-20)

I have a .bam alignment file and a genome reference .fasta file. I am looking for a easy to use tool (that I can reference in a publication) to calculate the percentage coverage of the reference by the alignment and if possible also: average depth of reads that cover the gene, min/max depths. Running plot would be nice but not essential.

I wrote some python code to calculate coverage percent, but I want to reference the tool I use in a paper and dont want to mess with making a git repo and linking to it in the paper just for this simple analysis.

**Tags:** rna-seq, phylogenetics

---

## 2 answers

### Answer by username_1 on 2021-03-21. Score: 2

You could use samtools coverage as explained in the manual of samtoools.
Here is a example which is also described on the manual site.
samtools coverage -r chr1:1M-12M input.bam

#rname  startpos  endpos    numreads  covbases  coverage  meandepth  meanbaseq  meanmapq
chr1    1000000   12000000  528695    1069995   9.72723   3.50281    34.4       55.8

> **Comments:**
> **username_2**: Are you sure that those statistics are the ones that make the most sense for RNASeq?  

---

### Answer by username_3 on 2021-03-21. Score: 0

I've used <https://genome.sph.umich.edu/wiki/BamUtil> before. I think this has all the functionality you want and the Devs are responsive which is nice.


---

