<p>You have a few options:</p>

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

<p>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. </p>

CC BY-SA 4.0
2020-04-25T22:22:23.527Z
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?
stack_learner
CC BY-SA 4.0
2020-04-26T07:00:44.343Z
You’re trying to make the library sizes similar.
Devon Ryan
CC BY-SA 4.0
2020-04-26T08:34:19.977Z
yes...so any cutoff is fine?
stack_learner
CC BY-SA 4.0
2020-04-26T08:46:58.613Z
Just eye ball a fraction from that graph.
Devon Ryan
CC BY-SA 4.0
2020-04-24T09:32:08.660Z
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 [https://ccb.jhu.edu/software/stringtie/index.shtml?t=manual] Will there be any problem?
stack_learner
CC BY-SA 4.0
2020-04-24T09:34:25.497Z
I don't use stringTie, so I can't comment with certainty.
Devon Ryan
CC BY-SA 4.0
2020-04-24T09:49:42.173Z
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?
stack_learner
CC BY-SA 4.0
2020-04-24T09:51:36.203Z
If you need 20% then 1234.2. 1234 is just a seed for reproducibility, `.2` is the fraction to keep.
Devon Ryan
CC BY-SA 4.0
2020-04-24T07:07:45.570Z
2020-04-24T07:07:45.570Z
Devon Ryan
<p>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:</p>

<p><a href="https://i.sstatic.net/eI2m8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eI2m8.png" alt="enter image description here"></a></p>

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

<p>Any help is appreciated. thanq.</p>

<r><rna-seq><differential-expression><gene-expression>
How to downsample some of the samples in RNA-seq data?
# How to downsample some of the samples in RNA-seq data?

(Asked by: username_0 on 2020-04-23)

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:

[![enter image description here](https://i.sstatic.net/eI2m8.png)](https://i.sstatic.net/eI2m8.png)

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.

**Tags:** r, rna-seq, differential-expression, gene-expression

---

## 1 answers

### Answer by username_1 on 2020-04-24. Score: 4 | Accepted answer

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.

> **Comments:**
> **username_0**: 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 [https://ccb.jhu.edu/software/stringtie/index.shtml?t=manual] Will there be any problem?  
> **username_1**: I don't use stringTie, so I can't comment with certainty.  
> **username_0**: 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?  
> **username_1**: If you need 20% then 1234.2. 1234 is just a seed for reproducibility, `.2` is the fraction to keep.  
> **username_0**: 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?  
> **username_1**: You’re trying to make the library sizes similar.  
> **username_0**: yes...so any cutoff is fine?  
> **username_1**: Just eye ball a fraction from that graph.  

---

