Differences between PCA plots in DESeq and FactoMineR
2
0
Entering edit mode
3.6 years ago

Hello! I'm creating PCA plots with a whole transcriptome dataset, which includes 26,828 'genes', to assess similarity between three groups (E, M and L). I'm doing differential expression analysis using DESeq, so I transformed my DESeqDataSet using VST, then used the plotPCA function from this package, with the following code:

library(DESeq)
plotPCA(vsd, intgroup = c("dev"), ntop = 26828)

This produced this PCA plot, with 78% variance in PC1 and 14% in PC2:

PCA plot produced by plotPCA

I'm not sure how to upload my transformed DESeqDataSet in an accessible format for trouble shooting. However, the above plotPCA function uses the stats package prcomp function to produce the same plot, with the following code:

pca<- prcomp(vsd.transposed)
pca$x %>%
  as.data.frame %>%
ggplot(aes(x=PC1,y=PC2)) + geom_point(size=3) +
  theme_bw(base_size=32) + 
  labs(x=paste0("PC1: ", percentVar[1], "% variance"),
       y=paste0("PC2: ", percentVar[2], "% variance")) +
  theme(legend.position="top")

Subsequently,I wanted to look at the genes and GO terms correlated to PC1 and PC2, which is possible using dimdesc in FactoMineR. I created another PCA plot of the same data using the FactoMineR function PCA.

library(FactoMineR)
FactoMine.pca <- PCA(vsd.transposed, graph = F) 
plot((FactoMine.pca), axes=c(1,2))

This plot looks fairly similar to the first one, but the proportion of variances explained by Dim 1 and 2 are quite different compared to the plot produced by plotPCA.

PCA plot produced by FactoMineR

Is this difference due to an error in my code or the computing method used by the two different functions? If this is the case, is there one which is generally preferred?

Thanks for your attention!

EDIT: Thank you for your help everyone - the difference was due to the use of scaling by default in FactoMineR but no scaling in plotPCA!

R DESeq PCA FactoMineR • 2.9k views
ADD COMMENT
0
Entering edit mode

Please see How to add images to a Biostars post to add your images properly. You need the direct link to the image, not the link to the webpage that has the image embedded (which is what you have used here)

Also, post your code/data on a GitHub Gist and paste the link to the gist here (See how-to post here). Don't use sites like ufile and force other users to download files just to help you. Remember, we're not customer support.

ADD REPLY
0
Entering edit mode

Thanks for the information, I have updated the post accordingly!

ADD REPLY
0
Entering edit mode
3.6 years ago
13530213 ▴ 10

Hi there, So, unfortunately I cannot see the plots and therefore not discuss them. However, there is a possibility that the PCA analysis was not centered and was in the other, or was scaled in one but not the other. I generally do center, but not scale my PCA analysis. Other then that, I should read up on the packages you used but I never heard of ;-) Cheers!

ADD COMMENT
1
Entering edit mode

As per this user's comment, please check the default values for each function, as some may have centering and scaling enabled or disabled by default.

I know that DESeq2::plotPCA() uses prcomp(), so, you should definitely be able to get those to produce the same result.

ADD REPLY
0
Entering edit mode

Thanks very much both - you are right, the plotPCA wasn’t scaled but the FactoMineR plot was! Problem solved!

ADD REPLY
0
Entering edit mode

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Upvote|Bookmark|Accept

ADD REPLY
0
Entering edit mode

My browser (Chrome) doesn’t seem to display the option to upvote any answers (it does for comments/replies), or the option to accept an answer. I have tried changing browsers and using the mobile site, but to no avail. Have you come across this before? Cheers!

ADD REPLY
0
Entering edit mode

That's an odd bug - I'll accept both answers on your behalf. What country are you trying to access the website from?

ADD REPLY
0
Entering edit mode

Thank you! The UK - it’s very strange, the add reply and add comment buttons are only working on my mobile too.

ADD REPLY
0
Entering edit mode

Are you telling me that they do not work on desktop/laptop machines?

ADD REPLY
0
Entering edit mode

Yes - as well as having no upvote or accept answer buttons, both my desktop and my laptop do not allow adding comments or replies. The “ADD COMMENT/REPLY” text is present, but not in a coloured box. When hovering over the text, the cursor changes as if selecting a button or link, but nothing happens when clicked. They are both Mac machines running OS X El Capitan.

ADD REPLY
0
Entering edit mode

Perhaps you are using some extension that is blocking the feature. Do you have javascript turned on?

ADD REPLY
0
Entering edit mode

Ah yeah that’s a good point. I do have javascript turned on yeah.

ADD REPLY
0
Entering edit mode

Maybe check Safari too, and/or Firefox (?) Sorry to drag this on.

ADD REPLY
0
Entering edit mode

I have the same issue on Safari too. Could it be related to my browser security settings? Both browsers give me a warning that the “certificate has an invalid issuer”.

ADD REPLY
0
Entering edit mode

I suggest to transfer the discussion to our Slack channel:

biostar.slack.com: Chat for the biostars community -- [ feel free to join ]

Here, it doesn't add anything. Thanks!

ADD REPLY
0
Entering edit mode
3.6 years ago
ATpoint 81k
PCA(X, scale.unit = TRUE, ncp = 5, ind.sup = NULL,quanti.sup = NULL, 
    quali.sup = NULL, row.w = NULL,col.w = NULL, graph = TRUE, axes = c(1,2))

These are the defaults of FactoMineR, it indeed scales values by default to unit variance whereas neither prcomp nor DESeq2 (calling prcomp) do, as suggested abovem by 13530213.

ADD COMMENT
0
Entering edit mode

Thank you very much, I didn’t realise that there is a difference in scaling. When I disabled the default scaling on FactoMineR it produced the same plot as the plotPCA: problem solved!

ADD REPLY

Login before adding your answer.

Traffic: 2223 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6