如何改变heatmap.2的颜色范围在R? [英] How to change heatmap.2 color range in R?
问题描述
我使用gplot产生热图,显示治疗组与配对对照组的log2倍变化。使用以下代码:
heatmap.2(as.matrix(SeqCountTable),col = redgreen(75),
density.info =none,trace =none,dendrogram = c(row),
symm = F,symkey = T,symbreaks = T,scale =none)
我输出一个具有实际倍数变化值的热图(即非Row-Z得分)之后,在每个生物学家最喜欢的红黑绿配色方案中。
log2倍变化的实际范围是-3 / +7,许多值在-2 / -1和+ 1 / + 2范围内,分别显示为深红色/绿色。这使得整个热图非常暗,很难解释。
- 是否有一种倾斜颜色渐变的方法,也就是说,从黑色到相当明亮的梯度在较小的范围内发生?
- 和/或将颜色范围更改为不对称,即数据所用的范围为-3 / + 7,而不是像当前尺度的-7 / + 7 ,黑色仍然居中在零?
symm = F,symkey = F,symbreaks = T,scale =none
解决colorRampPalette的颜色问题,并使用breaks参数指定每种颜色的范围,例如
colors = c(seq(-3,-2,length = 100),seq(-2,0.5,length = 100),seq(0.5,6,length = 100 ))
my_palette< - colorRampPalette(c(red,black,green))(n = 299)
总共
heatmap.2(as.matrix(SeqCountTable) ,col = my_palette,
breaks = colors,density.info =none,trace =none,
dendrogram = c(row),symm = F,symkey = F,symbreaks = T,scale =none)
I'm using gplot to produce a heatmap showing log2-fold changes of a treatment groups versus paired controls. With the following code:
heatmap.2(as.matrix(SeqCountTable), col=redgreen(75),
density.info="none", trace="none", dendrogram=c("row"),
symm=F,symkey=T,symbreaks=T, scale="none")
I output a heat map with real fold change values (i.e., non Row-Z score) which is what I'm after, in the Red-Black-Green color scheme that is every biologist's favorite!
The actual range of log2-fold change is -3/+7, with many values in the -2/-1 and +1/+2 range, which appear as dark red/green (respectively). This makes the whole heatmap quite dark and so difficult to interpret.
- Is there a way of skewing the color gradient to make it less linear? That is, so that the gradient from black to quite bright occurs over a smaller range?
- And / or change the color range to be asymmetric, i.e., to run from -3/+7, as the data does, rather than -7/+7 as the scale currently does, with black still centered on zero?
I got the color range to be asymmetric simply by changing the symkey argument to FALSE
symm=F,symkey=F,symbreaks=T, scale="none"
Solved the color issue with colorRampPalette with the breaks argument to specify the range of each color, e.g.
colors = c(seq(-3,-2,length=100),seq(-2,0.5,length=100),seq(0.5,6,length=100))
my_palette <- colorRampPalette(c("red", "black", "green"))(n = 299)
Altogether
heatmap.2(as.matrix(SeqCountTable), col=my_palette,
breaks=colors, density.info="none", trace="none",
dendrogram=c("row"), symm=F,symkey=F,symbreaks=T, scale="none")
这篇关于如何改变heatmap.2的颜色范围在R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!