简体   繁体   English

R heatmap.2键色

[英]R heatmap.2 key colour

I'm creating a heatmap using heatmap.2 and had a question about the scale of the colour key. 我正在使用heatmap.2创建一个热图,并且对颜色键的比例有疑问。 I have applied log10 to my data and have some negative values. 我已将log10应用到我的数据,并且具有一些负值。 However, the colour key is scaled between 0 and 0.3. 但是,颜色键在0到0.3之间缩放。 Where did this scale come from? 这个规模是从哪里来的?

library(gplots)
scalewhitered <- colorRampPalette(c("white", "red"), space = "rgb")(255)
heatmap.2(as.matrix(log10_normalised),Rowv=T, Colv=F,scale="none",     trace="none",labRow=rownames(log10_normalised), col=scalewhitered, xlab="", ylab="", mar=c(10,10))

Is it possible to make all the 0 values white and then show the non-zero numbers (including the negatives) as different shades of red? 是否可以将所有0值都设置为白色,然后将非零数字(包括负数)显示为不同的红色阴影? Thanks so much. 非常感谢。

The idea here is to create your own color scale (basically you have to define the ranges for the colors). 这里的想法是创建自己的色标(基本上必须定义颜色范围)。 You can use the colorRampPalette from the RColorBrewer package: 您可以从RColorBrewer包使用colorRampPalette:

http://cran.r-project.org/web/packages/RColorBrewer/ http://cran.r-project.org/web/packages/RColorBrewer/

Take a look at the following link where they found a solution of how to do it: 看一下下面的链接,他们找到了解决方法:

How to change heatmap.2 color range in R? 如何在R中更改heatmap.2颜色范围?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM