我想做一个PCA分析和可视化,看起来很容易,但我无法弄清楚如何让不同的组在不同的颜色。 我的数据如下所示:
V1 meanLL meanML meanHL meanFL
1 AT3G02730 22684834 24936025 22896942.1 26281180
2 AT5G51570 NaN 2946262 4513876.3 NaN
3 AT2G41680 7080077 2461699 1697517.9 5756359
4 AT5G19855 NaN 2655188 NaN 2242139
5 ATCG00190 1669609 1783529 721131.7 1943212
6 AT2G36885 2729459 5683605 7895497.2 6903475
>
我找到了一些有用的包
library(ggfortify)
library(ggplot2)
y <- read.table(header = TRUE, stringsAsFactors = FALSE,
text = " V1 meanLL meanML meanHL meanFL
1 AT3G02730 22684834 24936025 22896942.1 26281180
2 AT5G51570 NaN 2946262 4513876.3 NaN
3 AT2G41680 7080077 2461699 1697517.9 5756359
4 AT5G19855 NaN 2655188 NaN 2242139
5 ATCG00190 1669609 1783529 721131.7 1943212
6 AT2G36885 2729459 5683605 7895497.2 6903475")
df <-log(y[, c(2,3,4,5)])
df<- na.omit(df)
autoplot(prcomp(df))
所以我可以得到最基本的情节但是当谈到颜色时我迷失了,因为我的团体是我的列名......
autoplot(prcomp(df), data = y, colour = colnames(y)
autoplot(prcomp(df), data = y , loadings = TRUE)
我想要颜色,我的老板想要颜色,帮助,请帮助