【发布时间】:2020-09-04 22:08:06
【问题描述】:
我在包含 91 列和 2030 行的数据表上运行 prcomp 函数并获得了 PCA 图。然而,当我重新排序相同的数据表以更容易对数据点进行颜色编码时,我得到了一个完全不同的 PCA 图。
在 prcomp() 中列的顺序是否重要?
请注意,包含的代码是由我实验室以前的某个人为我提供的,他不再在这里询问。我对它在做什么有一个适度的了解。
感谢您的帮助!
pcaPlotter3d <- function(fileName, startColumn, endColumn){
x<- read.table(fileName, sep = '\t', header =TRUE, stringsAsFactors = FALSE)
pcaData <- prcomp(~., x[,startColumn:endColumn], na.action=na.exclude, scale = TRUE)
library(scatterplot3d)
colorList <- c(rep("magenta", 2), rep("blue", 12), rep("red",33), rep("purple", 2), rep("green", 6), rep("black",36))
shapeList <- c(rep(19, 91))#, rep(15, 24))
with (pcaData, {
pointsForPlot <- scatterplot3d(pcaData$rotation[,1:3], color=colorList,
pch = shapeList, main = "TAP Proteins PCA", mar = c(3,3,3,5), xlab = "PC1 (16.5%)", ylab = "PC2 (3.67%)", zlab = "PC3 (2.79%)",
col.grid = NULL)
pointsForPlot.coords <- pointsForPlot$xyz.convert(pcaData$rotation[,1:3])
legend(8,5, bty = "n", xpd = TRUE, cex = 0.75, inset = .1,
title = "Groups", c("Bio", "EF", "IF", "RF", "Rib", "Unk"),
col = c("magenta", "blue", "red", "purple", "green", "black") , pch = c(19,19,19,19,19,19));
})
print(summary(pcaData))
}
【问题讨论】:
-
你能发布两个图的链接吗?如果您考虑零轴周围的反射(即左右翻转或上下翻转),您的两个绘图是否等效?
-
我对问题进行了编辑以包含情节。它可能是数据的反映,但如果是,我很难看到它。
-
好吧,这可能确实是不同的 PCA 输出,因为 PC2 和 PC3 的惯性百分比不同
-
@agenis,我想知道轴标签中明显不同的惯性是否是错字。轴标签是自动生成的还是手动编码的? PC2(图 1 中的 -0.1 到 0.5,图 2 中的 -0.5 到 0.1)和 PC3(图 1 中的 -0.2 到 0.4,-0.4 到 0.2)的范围支持翻转假设......我们可以看到代码(并且,理想情况下,数据)? ... 3D 透视图使判断轴是否翻转变得特别困难。 2D 表示可能更容易。
-
轴标签/惯性值看起来是硬编码的。它们在地块之间有何不同???