# How to downsample some of the samples in RNA-seq data?

I have 40 samples and these are into two groups. I would like to perform a differential analysis between two groups. The library size of the samples is very low. But there are two samples (GroupA_12 and GroupB_2) in which the number of counts is too large compared to other samples. Please check the library sizes below:

I wanted to downsample these two cases and then would like to perform differential analysis. May I know how to downsample those two samples.

Any help is appreciated. thanq.

You have a few options:

1. Downsample the fastq files and rerun the entire analysis. You can do this with seqtk sample.
2. Downsample the BAM files, which you can do with samtools view -s.
3. Divide all of the counts in the counts files by some factor and round that to an integer.

I personally prefer option 2, since it's quick and doesn't usually have any side-effects unless you use two-pass alignment or did the quantification with something like salmon. Option 3 is always tempting, but I have to say I've never been convinced that this consistently produces similar enough results to options 1 or 2.

• thanks for the reply @Devon Ryan, Yes, I feel that the 3rd option is much easier. To use the 2nd option, I have to mention that the raw read counts of the transcripts were extracted from the stringtie step using prepDE.py python script [ccb.jhu.edu/software/stringtie/index.shtml?t=manual] Will there be any problem? Apr 24, 2020 at 9:32
• I don't use stringTie, so I can't comment with certainty. Apr 24, 2020 at 9:34
• ok. And if I have to use the 2nd option, Is this right? samtools view -s number GroupA_12.bam > GroupA_12_new.bam What I should give the fixed number for downsampling? Apr 24, 2020 at 9:49
• If you need 20% then 1234.2. 1234 is just a seed for reproducibility, .2 is the fraction to keep. Apr 24, 2020 at 9:51
• Small question. How to decide the fraction of reads to keep? I mean 0.2 or 0.5 or something else? On what basis I should give the fraction? Apr 25, 2020 at 22:22