This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Downsample BAM file according to coverage

I have a BAM file that has 170X whole exome coverage.

I would like to create a new BAM file from the original that has 100X genome coverage.

I know samtools view -s option will give me the result but what float digit I should give to get 100X coverage?

samtools alignment assembly

1 answer

-s FLOAT subsample reads (given INT.FRAC option value, 0.FRAC is the
           fraction of templates/read pairs to keep; INT part sets seed)

So 100/170 = 0.59 so you want to keep 59% of all reads, therefore use e.g. -s 1.59 where the .59 is the fraction to keep and the 1 is a random seed for reproducibility.

Thank you for the quick reply. That was completely correct and I got the required result.

Log in to answer this question.