heatmap绘制

  1. 整理出这样的group和表达谱数据,其中表达谱必须是矩阵


    heatmap绘制_第1张图片

    heatmap绘制_第2张图片
  2. 为热图上方的bar赋值

annotation_col = data.frame(Gender = group)
rownames(annotation_col) = colnames(expr_limma)
ann_colors = list(Type = c(F = "#FFA42D", M = "#A9D9DF"))

  1. 热图主程序

pdf("heatmap.pdf",width = 20,height = 60)
pheatmap(expr_limma,cellwidth = 8, cellheight = 1, fontsize = 8,
method="spearman", #计算gene或sample之间的相关性的方法,可选"pearson" (default), "kendall", or "spearman"
scale="row", #为基因做scale
cluster_rows=T,#为基因做聚类
cluster_cols=T,#为sample做聚类
color = colorRampPalette(c("navy", "white", "firebrick3"))(20),
show_colnames=F,show_rownames =F,
annotation_col = annotation_col,
annotation_colors = ann_colors,
#treeheight_row = "0",treeheight_col = "0",#不画树
border_color = "NA")
dev.off()

heatmap绘制_第3张图片

你可能感兴趣的:(heatmap绘制)