PlotPCA in DESeq2 doesn't produce exactly the same result as prcomp
1
0
Entering edit mode
Jonas • 0
@f91ff31c
Last seen 2.2 years 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!

Jonas

DESeq2 PCA • 2.0k views
ADD COMMENT
0
Entering edit mode

Is the one plot a mirror image of the other?

ADD REPLY
0
Entering edit mode
@mikelove
Last seen 6 days 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.

ADD COMMENT

Login before adding your answer.

Traffic: 528 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