rm(list = ls()) load(file = "step1output.Rdata")load(file = "step2output.Rdata")
一、主成分分析(Principal Component Analysis)
http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/112-pca-principal-component-analysis-essentials
dat=as.data.frame(t(exp))library(FactoMineR)library(factoextra) dat.pca <- PCA(dat, graph = FALSE)pca_plot <- fviz_pca_ind(dat.pca, geom.ind = "point", # show points only (nbut not "text") col.ind = Group, # color by groups palette = c("#00AFBB", "#E7B800"), addEllipses = TRUE, # Concentration ellipses legend.title = "Groups")pca_plotggsave(plot = pca_plot,filename = paste0(gse_number,"_PCA.png"))save(pca_plot,file = "pca_plot.Rdata")
二、热图,top 1000 sd
cg=names(tail(sort(apply(exp,1,sd)),1000))n=exp[cg,]
1. 直接画热图,对比不鲜明
library(pheatmap)annotation_col=data.frame(group=Group)rownames(annotation_col)=colnames(n) pheatmap(n, show_colnames =F, show_rownames = F, annotation_col=annotation_col)
2. 按行标准化
pheatmap(n, show_colnames =F, show_rownames = F, annotation_col=annotation_col, scale = "row", breaks = seq(-3,3,length.out = 100)) dev.off()