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
Is the one plot a mirror image of the other?