bedtools has always been my first stop when dealing with regions and coverages, but if the regions or features of interest (genes, exons,...) are described in bedfiles, the most efficient way I've found to do this is by using mosdepth, which not only is lightning fast, but also allows defining multiple thresholds in a single command:
mosdepth -x -Q 1 -t $THREADS -T 1,5,50 -b genes.bed $PREFIX $BAMFILE
mosdepth -x -Q 1 -t $THREADS -T 1,5,50 -b exons.bed $PREFIX $BAMFILE
Did you go through these: ?
How to calculate read depth and coverage for whole exome sequencing?
Calculating Exome Coverage
Calculate Per Exon/Per Gene Coverage
The samtools output is normal and expected, it is the per-base coverage for every single nucleotide in the genome.
Thanks everyone for the help. Unfortunately i am still not able to solve my problems. I tried the samtools coverage as well as bedtools geneomecov. following is the code i used and the screen shot of some lines of result. looks like samtools coverage is giving me coverage per chromosome. however i need it per exon or per gene or per genome. in 1X , 2X .....100X form.
samtools coverage input.bam
I also tried samtools bedcov following is the result chromosome wise . and not percentage coverage. samtools bedcov region.bed input.bam
Also i used bedtools genomecov
(inplace of .genome i used hg19.fa. plz guide how to get .genome file)
i also tried samtools stats and samtools depth. however not getting desire result form.
i would be really thankfull if anyone ca guide me further. i am really stuck at this point.
thanks in advance
reagards, sabeen
When using bedtools genomecov for your purposes, the genome file is not needed. This simple command will give you the sample coverage in bedgraph format, which you could later intersect with your features of interest:
Again, considering your initial question, I must insist in using mosdepth, as it is indeed intended to answer queries like the one you have in a very efficient manner.
Thanks every one for the help. finally able to get the result with all the help here.