I have a BAM file and a BED file for my own chromosome. I would like to get coverage per base and ideally construct a histogram of coverage across each gene.

The motivation is to visualise the coverage across each gene. If my experiment is good, I should expect uniform coverage. It's also important to compare the coverage near the boundary of the genes.

A R (bioconductor) solution is ideal, because I can directly visualise.

How to do it?


2 Answers 2


From your bam-file, you can generate a BED(-graph) of per base coverage with bedtools genomecov (use the -ibam, -d and if you want a BEDgraph also the -bg flags).

There are multiple R packages for bioconductor which read and visualise these, including sushi.


skymningen's suggestion of genomecov is absolutely correct. The command I use is:

bedtools genomecov -bg -ibam sorted.bam > sorted.wgx

This generates a BedGraph file.

Unfortunately, the R package sushi had a bug that it didn't generate anything if the interval I wanted is too small. I preferred IGV.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .