1. rm(list = ls())
  2. load(file = "step1output.Rdata")
  3. 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

  1. dat=as.data.frame(t(exp))
  2. library(FactoMineR)
  3. library(factoextra)
  4. dat.pca <- PCA(dat, graph = FALSE)
  5. pca_plot <- fviz_pca_ind(dat.pca,
  6. geom.ind = "point", # show points only (nbut not "text")
  7. col.ind = Group, # color by groups
  8. palette = c("#00AFBB", "#E7B800"),
  9. addEllipses = TRUE, # Concentration ellipses
  10. legend.title = "Groups"
  11. )
  12. pca_plot
  13. ggsave(plot = pca_plot,filename = paste0(gse_number,"_PCA.png"))
  14. save(pca_plot,file = "pca_plot.Rdata")

二、热图,top 1000 sd

  1. cg=names(tail(sort(apply(exp,1,sd)),1000))
  2. n=exp[cg,]

1. 直接画热图,对比不鲜明

  1. library(pheatmap)
  2. annotation_col=data.frame(group=Group)
  3. rownames(annotation_col)=colnames(n)
  4. pheatmap(n,
  5. show_colnames =F,
  6. show_rownames = F,
  7. annotation_col=annotation_col)

2. 按行标准化

  1. pheatmap(n,
  2. show_colnames =F,
  3. show_rownames = F,
  4. annotation_col=annotation_col,
  5. scale = "row",
  6. breaks = seq(-3,3,length.out = 100))
  7. dev.off()