R:居中heatmap.2键(gplots包) [英] R: Centering heatmap.2 key (gplots package)

查看:134
本文介绍了R:居中heatmap.2键(gplots包)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过heatmap.2()命令创建一个带有以0为中心的颜色键的热图(即白色-> 0,红色->大于0,蓝色->小于0),而保持scale ="none",因为我对绘制实际值的热图感兴趣.但是,使用以下代码行后,我所有的热图都不以零为中心:

I would like to create a heatmap via the heatmap.2() command with a color key that is centered on 0 (i.e. white color -> 0, red -> greater than 0, blue -> less than 0) while keeping scale="none" as I am interested in plotting a heatmap of the actual values. However, all of my heatmaps are not centered on zero upon using the following line:

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 x 3)数值矩阵.上述对heatmap.2()命令的输入有问题:

I thought that using the command symkey=TRUE would work, but it does not. The variable I am trying make a heatmap of is an (n x 3) matrix of numerical values. A problematic input to the heatmap.2() command described above follows:

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

谢谢您的时间.我期待着您的答复.

Thank you for your time. I look forward to your replies.

推荐答案

解决方案似乎只是将symbreaks添加到您的heatmap.2中.这是一个完全可复制的示例,其中包含您的数据:

The solution seem to be just adding symbreaks to your heatmap.2. Here is a fully reproducible example with your data:

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)

这篇关于R:居中heatmap.2键(gplots包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆