This is a test version of Biostars. For the public version, visit https://www.biostars.org.
randomly subsampling a bam file three times

I have a sample.bam file and I want to randomly sample 15 million reads from this file

I want to select 15 million reads 3 times

random_sample_15_million_1.bam, random_sample_15_million_2.bam random_sample_15_million_3.bam

I DONT want these 3 files to be identical.

chip-seq

1 answer

Count the total reads, and find what proportion of the total is 15M. Then Use Picard DownsampleSAM to select just that %. https://broadinstitute.github.io/picard/command-line-overview.html

Set the random seed to 1,2,3 and you'll have unique files.

If Picard gives you trouble, samtools view also has a downsample parameter.

in case it's not apparent ,

PROBABILITY=Double P=Double The probability of keeping any individual read, between 0 and 1. Default value: 1.0. This option can be set to 'null' to clear the default value.

use 0.25 for ~ 25% of the reads.

Log in to answer this question.