Principal Component Analysis (PCA)分析使用的是基于R語(yǔ)言的 prcomp() and princomp()函數(shù). 完成PCA分析一般有兩種方法:princomp()使用的是一種的spectral decomposition方法 prcomp() and PCA()[FactoMineR]使用的是SVD法
1data<-eset_dat 2data[1:5,1:5]##表達(dá)矩陣 3## GSM188013 GSM188014 GSM188016 GSM188018 GSM188020 4## 8.438846 8.368513 7.322442 7.813573 7.244615 5## A1CF 10.979025 10.616926 9.940773 10.413311 9.743305 6## A2M 6.565276 6.422112 8.142194 5.652593 5.550033 7## A4GALT 7.728628 7.818966 8.679885 7.048563 5.929258 8## A4GNT 10.243388 10.182382 9.391991 8.779887 9.431585 9metdata[1:5,1:5] 10## title 11## GSM188013 DMSO treated MCF7 breast cancer cells [HG-U133A] Exp 1 12## GSM188014 Dioxin treated MCF7 breast cancer cells [HG-U133A] Exp 1 13## GSM188016 DMSO treated MCF7 breast cancer cells [HG-U133A] Exp 2 14## GSM188018 Dioxin treated MCF7 breast cancer cells [HG-U133A] Exp 2 15## GSM188020 DMSO treated MCF7 breast cancer cells [HG-U133A] Exp 3 16## geo_accession status submission_date 17## GSM188013 GSM188013 Public on May 12 2007 May 08 2007 18## GSM188014 GSM188014 Public on May 12 2007 May 08 2007 19## GSM188016 GSM188016 Public on May 12 2007 May 08 2007 20## GSM188018 GSM188018 Public on May 12 2007 May 08 2007 21## GSM188020 GSM188020 Public on May 12 2007 May 08 2007 22## last_update_date 23## GSM188013 May 11 2007 24## GSM188014 May 11 2007 25## GSM188016 May 11 2007 26## GSM188018 May 11 2007 27## GSM188020 May 11 2007 28##構(gòu)建group_list 29group_list<-rep(c("Treat","Control"),3) 30colnames(data)<-group_list 31library(factoextra) 32## Warning: package 'factoextra' was built under R version 3.5.3 33## Loading required package: ggplot2 34## Welcome! Related Books: `Practical Guide To Cluster Analysis in R` at https:///13EFCZ 35## 計(jì)算PCA 36data<-t(data)##轉(zhuǎn)換數(shù)據(jù)至行為sample,列為gene 37data<-as.data.frame(data)##注意數(shù)據(jù)要轉(zhuǎn)換為數(shù)據(jù)框 38res.pca <- prcomp(data, scale = TRUE) 39##展示主成分對(duì)差異的貢獻(xiàn) 40fviz_eig(res.pca) Fig21## 可視化結(jié)果 2fviz_pca_ind(res.pca, 3 col.ind = group_list, # 顏色對(duì)應(yīng)group信息 4 palette = c("#00AFBB", "#FC4E07"), 5 addEllipses = TRUE, # Concentration ellipses 6 ellipse.type = "confidence", 7 legend.title = "Group",## Legend名稱 8 repel = TRUE 9 ) Fig3