Question: Differences between PCA plots in DESeq and FactoMineR
0
gravatar for caitlin.mcandry
4 days ago by
caitlin.mcandry0 wrote:

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!

factominer deseq pca R • 182 views
ADD COMMENTlink modified 2 days ago • written 4 days ago by caitlin.mcandry0

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 REPLYlink modified 4 days ago • written 4 days ago by RamRS30k

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

ADD REPLYlink written 4 days ago by caitlin.mcandry0
0
gravatar for 13530213
4 days ago by
1353021310
1353021310 wrote:

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 COMMENTlink written 4 days ago by 1353021310
1

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 REPLYlink written 4 days ago by Kevin Blighe65k

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

ADD REPLYlink modified 4 days ago • written 4 days ago by caitlin.mcandry0

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 REPLYlink written 4 days ago by genomax89k

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 REPLYlink written 4 days ago by caitlin.mcandry0

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

ADD REPLYlink written 3 days ago by RamRS30k

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

ADD REPLYlink written 3 days ago by caitlin.mcandry0

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

ADD REPLYlink written 3 days ago by RamRS30k

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 REPLYlink written 3 days ago by caitlin.mcandry0

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

ADD REPLYlink written 3 days ago by genomax89k

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

ADD REPLYlink written 3 days ago by caitlin.mcandry0

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

ADD REPLYlink written 3 days ago by Kevin Blighe65k

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 REPLYlink written 3 days ago by caitlin.mcandry0

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 REPLYlink written 3 days ago by ATpoint38k
0
gravatar for ATpoint
4 days ago by
ATpoint38k
Germany
ATpoint38k wrote:
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 COMMENTlink written 4 days ago by ATpoint38k

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 REPLYlink written 4 days ago by caitlin.mcandry0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1830 users visited in the last hour