https://blog.csdn.net/sinat_38163598/article/details/72770404
https://shengxin.ren/article/107
> library(pheatmap)
> pheatmap(data,fontsize=9, fontsize_row=6) #最简单地直接出图
> pheatmap(data, scale = "row", clustering_distance_row = "correlation", fontsize=9, fontsize_row=6) #改变排序算法
> pheatmap(data, color = colorRampPalette(c("navy", "white", "firebrick3"))(50), fontsize=9, fontsize_row=6) #自定义颜色
> pheatmap(data, cluster_row=FALSE, fontsize=9, fontsize_row=6) #关闭按行排序
> pheatmap(data, legend = FALSE, fontsize=9, fontsize_row=6) #关闭图例
> pheatmap(data, cellwidth = 6, cellheight = 5, fontsize=9, fontsize_row=6) #设定格子的尺寸
> color.map <- function(mol.biol) { if (mol.biol=="ALL1/AF4") 1 else 2 }
> patientcolors <- unlist(lapply(esetSel$mol.bio, color.map))
> hc<-hclust(dist(t(data)))
> dd.col<-as.dendrogram(hc)
> groups <- cutree(hc,k=7)
> annotation<-data.frame(Var1=factor(patientcolors,labels=c("class1","class2")),Var2=groups)
> pheatmap(data, annotation=annotation, fontsize=9, fontsize_row=6) #为样品分组
> Var1 = c("navy", "skyblue")
> Var2 = c("snow", "steelblue")
> names(Var1) = c("class1", "class2")
> ann_colors = list(Var1 = Var1, Var2 = Var2)
> pheatmap(data, annotation=annotation, annotation_colors = ann_colors, fontsize=9, fontsize_row=6) #为分组的样品设定颜色
clust=pheatmap(log2(data+20),fontsize = 6,scale = 'column',show_rownames = F,color = colorRampPalette(c("blue", "white", "red"))(100))
annotation_col = data.frame(ClassGene = factor(paste0('Cluster',cutree(clust$tree_col,3))))
rownames(annotation_col) = colnames(data)
pheatmap(log2(data+20),fontsize = 6,scale = 'column',show_rownames = F,annotation_col = annotation_col,color = colorRampPalette(c("blue", "white", "red"))(100))