三周合计15天的数据挖掘授课学员一点一滴整理的授课知识点笔记哦,还有互动练习题哈,欢迎大家点击文末的阅读原文去关注我们学员的公众号哦!
生信技能树学习笔记
GEO分析之PCA和热图
rm(list = ls()) load(file = "step1output.Rdata")load(file = "step2output.Rdata")#输入数据:exp和Group#Principal Component Analysis#http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/112-pca-principal-component-analysis-essentials # 1.PCA 图----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_plotsave(pca_plot,file = "pca_plot.Rdata") # 2.top 1000 sd 热图----cg=names(tail(sort(apply(exp,1,sd)),1000))#挑出标准差/方差里最大的1000个基因n=exp[cg,] # 直接画热图,对比不鲜明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 # cluster_cols=F#取消组间聚类) # 按行标准化pheatmap(n, show_colnames =F, show_rownames = F, annotation_col=annotation_col, scale = "row", breaks = seq(-3,3,length.out = 100) ) dev.off() # 关于scale的进一步学习:zz.scale.R |
---|
PCA
热图