How to sub-sample .bam file to target coverage?
0
0
Entering edit mode
3.3 years ago
hivemind ▴ 20

Hi,

I have .bam files for blood samples from which I extract signals. Let's assume my samples have a 30x coverage and my signal of interest is nicely detectable. To see how well the signal is detectable with lower coverage samples, I want to downsample to 20x, 10x, etc. Is there an easy way to do this?

So far I had a closer look at samtools view -s, but it takes only the target fraction and not a target coverage. Is there a program that lets me specify the target coverage that generalizes well for multiple samples with different start coverage?

QC downsample sequencing coverage • 1.4k views
ADD COMMENT
1
Entering edit mode

If you want to downsample from 30x to 20x then then just do samtools --subsample 0.66 .....

ADD REPLY
1
Entering edit mode

This assumes that unaligned reads are not in the BAM file? If they are then it may be best to filter those out first. someX coverage is a fluid term and subject to interpretation so it could mean different things to different people.

ADD REPLY
0
Entering edit mode

I know... If I had one sample or even five samples this would be my solution. I have hundreds of samples, all with different coverage and I was wondering whether there is a simpler solution that for example caps the max coverage to a certain value so that I don't have to calculate the fraction for each sample.

ADD REPLY

Login before adding your answer.

Traffic: 2002 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6