问题描述
有人告诉我如何使用pheatmap将表达式键索引和图例键显示在热图的底部吗?您可以使用以下代码生成热图。 非常感谢!
test = matrix(rnorm(200),20,10)
test[1:10,seq(1,10,2)] = test[1:10,2)] + 3
test[11:20,seq(2,2)] = test[11:20,2)] + 2
test[15:20,2)] = test[15:20,2)] + 4
colnames(test) = paste("Test",1:10,sep = "")
rownames(test) = paste("Gene",1:20,sep = "")
annotation_col = data.frame(
CellType = factor(rep(c("CT1","CT2"),5)),Time = c("A","B","C","D","E"))
rownames(annotation_col) = paste("Test",sep = "")
ann_colors = list(
Time = c(A = "white",B= "firebrick",C= "#fdbb84",D = "#e34a33",E = "red"),CellType = c(CT1 = "#1B9E77",CT2 = "#D95F02"))
library("pheatmap")
pheatmap(test,annotation_col = annotation_col,annotation_colors = ann_colors)
解决方法
照片地图似乎没有提供控制图例位置的功能。
绘制热图的代码可以在https://github.com/raivokolde/pheatmap上找到。
检出R/pheatmap-package.r
文件。
该图例似乎很难编码,请参见# Legend position
和draw_legend = function(color,breaks,legend,...