PlotPCA in DESeq2 doesn't produce exactly the same result as prcomp
Entering edit mode
Jonas • 0
Last seen 4 days ago
United Kingdom

Hi: I am having trouble with PlotPCA because the final plot is showing different values than the customed method using prcomp below (and it is supposed the same method as plotPCA in DESeq2 source code)

I have loaded the data into DESeq2, and after vst transformation of the data

ntop = 500
rv <- rowVars(assay(vsd))
  select <- order(rv, decreasing = TRUE)[seq_len(min(ntop,length(rv)))]
   pca <- prcomp(t(assay(vsd)[select, ]))
  percentVar <- pca$sdev^2/sum(pca$sdev^2)
ggplot(data = d, aes_string(x = "PC1", y = "PC2")) + geom_point(size = 3) + xlab(paste0("PC1: ", round(percentVar[1] * 100), "% variance")) + ylab(paste0("PC2: ", round(percentVar[2] * 100), "% variance")) + coord_fixed()

It produces a graph with PC1 being 75% and PC2 being 11%

However, when I tried

plotPCA(vsd, intgroup = "drug")

It gives me another plot with PC1 being 75% and PC2 being 11%.

However, the position of the dots changed. I completely lost on this since they are supposed to be doing the same thing but the output has been quite different. The scale of the PC1 and PC2 axis also doubled when not using plotPCA.

Any idea what could have happened?

Many thanks!


DESeq2 PCA • 95 views
Entering edit mode

Is the one plot a mirror image of the other?

Entering edit mode
Last seen 22 hours ago
United States

You don't show your code for d so I can't debug, but I bet you can debug on your end by copying the entire code of the function (which will be identical to plotPCA), and then trying to spot the difference between that and what you are running.


Login before adding your answer.

Traffic: 476 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6