我面对墙,我有我的数据,我想要显示PCA。数据看起来像这样:
mean_HL mean_LL mean_FL mean_ML
AT1G01080.1 6659961 2481626 3334466 1917721
AT1G01090.1 14305565 15664978 16938777 13772388
AT1G01320.1 2417028 7043427 15705767 6236322
AT1G01790.1 1689920 4840314 6193037 1870497
AT1G02140.1 5878921 3766975 3536914 3674864
AT1G02150.1 3271086 2408324 1741409 4520847
>
PCA我这样计算
tbl_log <- log(MERGE[, 1:4])
Light_mean_PCA <- prcomp(tbl_log,
center = TRUE,
scale. = TRUE)
接下来我想要想象一下,这就是墙壁进来的地方。
library(devtools)
install_github("ggbiplot", "vqv")
library(ggbiplot)
g <- ggbiplot(Light_mean_PCA, obs.scale = 1, var.scale = 1,
groups = row.names(Light_mean_PCA), ellipse = TRUE,
circle = TRUE)
g <- g + scale_color_discrete(name = "")
g <- g + theme(legend.direction = 'horizontal',
legend.position = 'top')
print(g)
或以更简单的方式
library(ggfortify); library(ggplot2)
autoplot(prcomp(tbl_log), data = MERGE, colour = MERGE[,c(1,2,3,4)])
我这样做。但是我希望颜色取决于:原始表中的mean_HL,mean_LL,mean_FL,mean_ML。
如何在实验中为四种不同的光照条件获得4种不同的颜色?