[英]How to label specific data points on a PCA plot in r using ggplot
[英]how to label an individual data point in PCA Plot
我使用 R 中的 prcomp 創建了一個 PCA plot 使用:
> input <- read_excel("input.xlsx")
> data<-input[,!names(input) %in% "gene"]
> data1<-t(as.matrix(data[-1])) %*% as.matrix(data[-1]) / ncol(data)
> res.pca <- prcomp(data1, scale = TRUE)
> par(cex=0.5)
> plot(res.pca$x[,1],res.pca$x[,2], xlab="PC1", ylab = "PC2", main = "PC1 / PC2 - plot")
input.xlsx
文件如下所示:
gene Sample1 Sample2 Sample3
A 13.932431 5.366284 6.93992
B 21.111017 0.662061 1.563687
C 26.471751 0.932416 1.673144
D 27.597507 36.591138 28.371248
E 35.324703 0 1.462438
我想將 label 添加到代表此 PCA Sample1
中 Sample1 的數據點,並將其塗成紅色。 謝謝你的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.