[英]R heatmap sparse and diverse matrix
I am trying to generate a heatmap in R for a dataset, which has a broad value range. 我正在尝试在R中为数据集生成一个热图,该值范围很广。 The dataset mostly contains zeros which shall be colored white.
数据集主要包含零,应将其着色为白色。 Most of the remaining value are range between 1 and 200 with a decreasing density.
其余大多数值的范围在1到200之间,并且密度减小。 A few values range between 201 and 16000.
某些值介于201和16000之间。
I would like to create colored bins for the heatmap in advance, for instance: 0 white 1-20 green 21-70 yellow 71-200 orange 201-16000 red 我想预先为热图创建有色垃圾箱,例如:0白色1-20绿色21-70黄色71-200橙色201-16000红色
Any ideas on that? 有什么想法吗?
Thx! 谢谢!
The function heatmap.2
in gplots
has built-in breaks definition. 该功能
heatmap.2
在gplots
内置了休息的定义。
library(gplots)
x <-matrix(c(seq(0,90,10),runif(90,0,16000)),10)
my.breaks <-c(0,1,20,70,200,16000)
my.col=c("white","green","yellow","orange","red")
heatmap.2(x, col = my.col, breaks=my.breaks)
尝试使用cut()函数创建与所需颜色相对应的因数,然后将颜色与该因数的每个值关联。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.