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.


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
  • $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$ – StupidWolf Mar 22 at 16:09
  • 1
    $\begingroup$ Are you sure that those statistics are the ones that make the most sense for RNASeq? $\endgroup$ – swbarnes2 Mar 22 at 16:15
  • $\begingroup$ @StupidWolf thanks for the hint. That the link become invalid, didn't came up my mind. So thanks for the hint. But the link was not supposed to be the answer. My answer was samtools coverage and the link should only give more information about the exact usage. $\endgroup$ – Mr_Z Mar 22 at 19:06
  • $\begingroup$ ok cool. that looks good $\endgroup$ – StupidWolf Mar 22 at 19:08

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.