<p>The general goal of PCA in RNA-seq can be stated as, &quot;I'd like a low-dimension representation of my data to allow easy assessment of the gross structure of my samples, specifically for assessing missing batch effects, samples swaps, etc.&quot; Ideally, this low-dimension representation can fit into a plot or two. In other words, we'd like the first 2 (maybe 3) PCs to explain a reasonable amount of variation. A few things to note from this alone:</p>
<ul>
<li>The number of differentially expressed genes were not mentioned. They have no relevance here.</li>
<li>There was no mention made of the treatment groups clustering together. Seeing this is <strong>NOT</strong> a goal of PCA.</li>
</ul>
<p>As you have noticed, the more input rows (genes, assuming you haven't already transposed it) the less variation explained by the first 2 principal components (PCs). On the flip side, the more rows you input the better PCA is describing the structure of your entire dataset.</p>
<p>Question: Do I really care about the gross structure of the entire dataset?</p>
<p>Answer: No, I just want to see problems that I might need to account for.</p>
<p>So you really don't have to use all of the data in the PCA, just the bits that will allow you to see any issues. In general that'll be the few hundred most-variable genes (after some reasonable transformation so you're not just looking at the most highly expressed genes!). <strong>The exact number shouldn't really matter very much, something in the range of 300-500 most variable genes should suffice.</strong> A common practice is to just randomly pick a nice round number somewhere in or around this range. This is not a number that needs optimization unless perhaps you have a very large number of samples and therefore PC1 and PC2 only account for a small (say 10-20%) percentage of the variation, in which case you're better off looking at either a number of difference principal components or using a different dimension reduction technique, such as UMAP.</p>

CC BY-SA 4.0
2020-11-30T11:54:31.770Z
Thanks, this was a very clear answer. Like you said, when using all the genes, both PC1 and 2 account already for almosth 50% of variance which is "strong" enough to my belief and to support my dataset. Thnaks again for the discussion above.
Ecg
CC BY-SA 4.0
2020-11-30T08:34:10.510Z
2020-11-30T08:34:10.510Z
Devon Ryan
<p>I am working with a set of RNASeq dataset. I have about 4000 observations (genes) on 20 samples and plotting a PCA I found the clustering doesn't vary much when I use different number of genes, but the % variance of PC1 and PC2 does. I have ~1300 DEG. But how do you select a sensible cutoff for the number of genes/observations to explain PCA variance? Would it be correct to select the number of genes that are DEG which account for &gt;50% of the variance between PC1 and 2?</p>
<p>Few examples:</p>
<ul>
<li><p>All genes: PC1(34%), PC2(14%)</p>
</li>
<li><p>Top1000: PC1(45%), PC2(17%)</p>
</li>
<li><p>Top500: PC1(49%), PC2(19%)</p>
</li>
<li><p>Top50: PC1(55%), PC2(24%)</p>
</li>
<li><p>Top 5: PC1(75%), PC2(24%)</p>
</li>
</ul>

CC BY-SA 4.0
2020-11-29T18:17:11.553Z
Hi @Ecg ... this is a good question. What we need to understand is why not dump all the data into the PCA - it can certainly handle it. What you appear to be saying is 'how can I re-jig PCA to give a result when I get no result'. If you can edit your question to help here that would be great rather than a priori assume PC1 and PC2 comprise max resolution
M__
CC BY-SA 4.0
2020-11-29T18:24:32.203Z
Yes, you are right, I am trying to understand where to set up the cut off to dump only relevant data into the PCA, however I do not understand when you say "when I get no result".
Ecg
CC BY-SA 4.0
2020-11-29T19:29:22.720Z
By result I mean clear clusters within PCA
M__
CC BY-SA 4.0
2020-11-29T19:31:43.290Z
S the cluster IS HAPPENING, just the less genes I select, the more clear (more reproducibility between replicates etc), just I am unsure on how many genes I should select.
Ecg
CC BY-SA 4.0
2020-11-29T21:02:56.683Z
Hi, yes I'd guessed this. The more data the fuzzier the signal. There's possibly a way foward, its not to reduce the amount of data .. in 'big data' its not cool. I can't remember its implemented though @StupidWolf might know. Hmmj looking at 'all genes' trapping a limited' variance that is weird.
M__
CC BY-SA 4.0
2020-11-29T21:23:56.217Z
Of course, you can subset however you want. You just have to adjust the message and be clear when communicating such a result. In this case, you have to specify that your PC1 explains 50% of the variance of _all DE genes_, or _the top 1000 most variable genes_.You however can no longer claim the PC explains 50% of the dataset.
Bastian Schiffthaler
CC BY-SA 4.0
2020-11-29T22:45:40.450Z
If you are using DESeq2, you are performing a PCA on the top 1000 most variables genes and plotting that. Some of your DEGs might be among these genes but there might be other factors other than the condition of your interest. Agree with Bastian its a a matter of what you want to convey with this PCA
StupidWolf
CC BY-SA 4.0
2020-11-29T22:45:49.530Z
And it's not very clear from your question..
StupidWolf
CC BY-SA 4.0
2020-11-29T23:31:14.333Z
This is not really what PCA is for, if I understand the question correctly. You don't select observations to "explain" PCA variance, that is more a feature of inferential tools like e.g. ANOVA. I would prefer to use some other measure to discard genes that are simply not informative or measured accurately. For example, first throw out low-expressed or non-expressed genes that are in the noise range. If what you want is to find a minimal set of genes that discriminate between two "clusters", then there are much better tools to do that than PCA, e.g. LDA or something like that.
Maximilian Press
CC BY-SA 4.0
2020-11-30T11:52:50.253Z
Thanks for the discussion from all of you. Just to clarify, my PCA shows three main clusters which coincide with my "conditions", thefeore my PCA would be a visual supporting information that the genes are expressed differently between these three clusters. So I believe, like @Devon mentioned below that the number do not really matter, just by showing the top most variable genes should show enough evidence that these clusters are separated, because using all genes both PC1 and 2 already account for a reasonable "big" percentage of variance (48%).
Ecg
<rna-seq><deseq2><pca>
What is a sensible number of gene/observations to explain PCA variance?
# What is a sensible number of gene/observations to explain PCA variance?

(Asked by: username_0 on 2020-11-29)

I am working with a set of RNASeq dataset. I have about 4000 observations (genes) on 20 samples and plotting a PCA I found the clustering doesn't vary much when I use different number of genes, but the % variance of PC1 and PC2 does. I have ~1300 DEG. But how do you select a sensible cutoff for the number of genes/observations to explain PCA variance? Would it be correct to select the number of genes that are DEG which account for >50% of the variance between PC1 and 2?

Few examples:

* All genes: PC1(34%), PC2(14%)
* Top1000: PC1(45%), PC2(17%)
* Top500: PC1(49%), PC2(19%)
* Top50: PC1(55%), PC2(24%)
* Top 5: PC1(75%), PC2(24%)

**Tags:** rna-seq, deseq2, pca
> **Comments:**
> **username_1**: Hi @Ecg ... this is a good question. What we need to understand is why not dump all the data into the PCA - it can certainly handle it. What you appear to be saying is 'how can I re-jig PCA to give a result when I get no result'. If you can edit your question to help here that would be great rather than a priori assume PC1 and PC2 comprise max resolution  
> **username_0**: Yes, you are right, I am trying to understand where to set up the cut off to dump only relevant data into the PCA, however I do not understand when you say "when I get no result".  
> **username_1**: By result I mean clear clusters within PCA  
> **username_0**: S the cluster IS HAPPENING, just the less genes I select, the more clear (more reproducibility between replicates etc), just I am unsure on how many genes I should select.  
> **username_1**: Hi, yes I'd guessed this. The more data the fuzzier the signal. There's possibly a way foward, its not to reduce the amount of data .. in 'big data' its not cool. I can't remember its implemented though @StupidWolf might know. Hmmj looking at 'all genes' trapping a limited' variance that is weird.  
> **username_2**: Of course, you can subset however you want. You just have to adjust the message and be clear when communicating such a result. In this case, you have to specify that your PC1 explains 50% of the variance of _all DE genes_, or _the top 1000 most variable genes_.You however can no longer claim the PC explains 50% of the dataset.  
> **username_3**: If you are using DESeq2, you are performing a PCA on the top 1000 most variables genes and plotting that. Some of your DEGs might be among these genes but there might be other factors other than the condition of your interest. Agree with Bastian its a a matter of what you want to convey with this PCA  
> **username_3**: And it's not very clear from your question..  
> **username_4**: This is not really what PCA is for, if I understand the question correctly. You don't select observations to "explain" PCA variance, that is more a feature of inferential tools like e.g. ANOVA. I would prefer to use some other measure to discard genes that are simply not informative or measured accurately. For example, first throw out low-expressed or non-expressed genes that are in the noise range. If what you want is to find a minimal set of genes that discriminate between two "clusters", then there are much better tools to do that than PCA, e.g. LDA or something like that.  
> **username_0**: Thanks for the discussion from all of you. Just to clarify, my PCA shows three main clusters which coincide with my "conditions", thefeore my PCA would be a visual supporting information that the genes are expressed differently between these three clusters. So I believe, like @Devon mentioned below that the number do not really matter, just by showing the top most variable genes should show enough evidence that these clusters are separated, because using all genes both PC1 and 2 already account for a reasonable "big" percentage of variance (48%).  

---

## 1 answers

### Answer by username_5 on 2020-11-30. Score: 3 | Accepted answer

The general goal of PCA in RNA-seq can be stated as, "I'd like a low-dimension representation of my data to allow easy assessment of the gross structure of my samples, specifically for assessing missing batch effects, samples swaps, etc." Ideally, this low-dimension representation can fit into a plot or two. In other words, we'd like the first 2 (maybe 3) PCs to explain a reasonable amount of variation. A few things to note from this alone:

* The number of differentially expressed genes were not mentioned. They have no relevance here.
* There was no mention made of the treatment groups clustering together. Seeing this is **NOT** a goal of PCA.

As you have noticed, the more input rows (genes, assuming you haven't already transposed it) the less variation explained by the first 2 principal components (PCs). On the flip side, the more rows you input the better PCA is describing the structure of your entire dataset.

Question: Do I really care about the gross structure of the entire dataset?

Answer: No, I just want to see problems that I might need to account for.

So you really don't have to use all of the data in the PCA, just the bits that will allow you to see any issues. In general that'll be the few hundred most-variable genes (after some reasonable transformation so you're not just looking at the most highly expressed genes!). **The exact number shouldn't really matter very much, something in the range of 300-500 most variable genes should suffice.** A common practice is to just randomly pick a nice round number somewhere in or around this range. This is not a number that needs optimization unless perhaps you have a very large number of samples and therefore PC1 and PC2 only account for a small (say 10-20%) percentage of the variation, in which case you're better off looking at either a number of difference principal components or using a different dimension reduction technique, such as UMAP.

> **Comments:**
> **username_0**: Thanks, this was a very clear answer. Like you said, when using all the genes, both PC1 and 2 account already for almosth 50% of variance which is "strong" enough to my belief and to support my dataset. Thnaks again for the discussion above.  

---

