Hi, I have a list of regions in a BED file and I want to know the average depth of each region as calculated from a BAM file, ideally as the fourth column in the output file (like an extra column in the BED file). Is there some combination of Samtools/Bedtools and awk that I can use to get this? Thanks!
Thanks for the reply, RamRS! Running into installation issues with mosdepth. Any way either samtools or bedtools can do this for me?
Yeah samtools should be able to do this, but trust me - mosdepth is far quicker. What problems are you running into? If you have access to
conda
, you should justThanks, RamRS. I was able to install it using docker but ran into error:
I also installed the latest htslib from http://www.htslib.org/download/
Any idea how I can fix this? Thanks so much for your help.
Sorry, I don't know Docker, so I can't say if that error is Docker based or mosdepth based. I recognize the HTSLIB error though. What is the output of
Thank you for mentioning mosdepth. I had never heard of it before. I needed to extract the average per-base coverage of every aligned fragment (of which I had ~25,000,000 per sample) in 10 sequencing run samples. Samtools depth just calculated the coverage of all bases that were covered by any region in the BED file, instead of calculating coverage on each region separately. Samtools bedcov did what I asked, but took hours to run on a single sample. I installed mosdepth and I have no idea how, but mosdepth ran in about 5 minutes per sample and gave me exactly what I needed. I appreciate it!!!