我想通过heatmap.2()命令创建一个热图,其颜色键以0为中心(即白色-> 0,红色->大于0,蓝色->小于0),同时保持scale=为“none”,因为我对绘制实际值的热图感兴趣。但是,在使用下面这行代码时,我的所有热图都不是以零为中心的:
library(gplots)
outputHeatmap <- heatmap.2(heatmapInputActual, dendrogram="none", Rowv=FALSE,
Colv=FALSE, col= bluered(256), scale="none", key=TRUE, density.info="none",
trace="none", cexRow=0.125, cexCol=0.125, symm=FALSE, symkey=TRUE)我原以为使用命令symkey=TRUE会起作用,但事实并非如此。我尝试制作热图的变量是一个(n×3)数值矩阵。上述heatmap.2()命令的输入有问题,如下所示:
8.408458 5.661144 0.00000000
4.620846 4.932283 -0.46570468
-4.638912 -3.471838 -0.12146109
-4.822829 -3.946024 0.06403327
3.948832 4.520447 -0.31945941谢谢您抽时间见我。我期待着你的回复。
发布于 2012-04-09 03:16:53
解决方案似乎只是将symbreaks添加到您的heatmap.2中。下面是一个完全可重现的数据示例:
library(gplots)
#read your example data
heatmapInputActual <- read.table(textConnection(
"8.408458 5.661144 0.00000000
4.620846 4.932283 -0.46570468
-4.638912 -3.471838 -0.12146109
-4.822829 -3.946024 0.06403327
3.948832 4.520447 -0.31945941
"),as.is=TRUE)
#convert sample data to matrix
heatmapInputActual <- as.matrix(heatmapInputActual)
#just add symbreaks to the end of your code
heatmap.2(heatmapInputActual, dendrogram="none", Rowv=FALSE, Colv=FALSE,
col = bluered(256), scale="none", key=TRUE, density.info="none",
trace="none", cexRow=0.125, cexCol=0.125, symm=F,symkey=T,symbreaks=T)

https://stackoverflow.com/questions/10048543
复制相似问题