转录组-差异基因热图

top_de_exp<-dplyr::slice(de_result2,1:20)%>%#挑取差异最大的
  select(-c(2:8))%>%#去掉2-8列
  column_to_rownames(var="id")#列变行

de_result2为上一篇转录组-火山图得到的数据!

#第一种做图方式

library(pheatmap)
pheatmap(log10(top_de_exp+1),
         #cluster_rows = F,#顺序按照导入表一致且左侧不聚类,一般不用
         #cluster_cols = F,#上面不聚类,一般不用
         show_colnames = F)#去掉行名

#第二种做图方式:标准化之后

pheatmap(top_de_exp,
         scale = "row",
       show_rownames = F)#不显示基因名字/列名

#第三种做图方式

#cols<-list(
  #group=c(C="#4DBBD5FF",P="#00FFFF",HP="#EE82EE",HC="#FFA07A"))#不运行

pheatmap(top_de_exp,
         scale = "row",
         color = colorRampPalette(c("green","white","red"))(200),#绿-红:200个颜色
         annotation_col = sample_info[c("group")],#sample_info表格第一列必须是分组情况,不能为“1/2/3..”,否则group无颜色
         annotation_colors=list( #annotation_colors=cols#
           group=c(C="#4DBBD5FF",
                   P="#00FFFF",
                   HP="#EE82EE",
                   HC="#FFA07A")),
         cutree_rows = 2)