我正在使用gplots和Rcolorbrewer通过heatmap2()函数制作热图。
我的数据有零,表示此样本中没有记录任何数据。为了创建热图,我希望这些零被涂成白色,其余的在三种颜色的图例中。
以下是到目前为止的代码:
my_palette <- colorRampPalette(c("blue", "green", "red"))(n = 299)
col_breaks = c(seq(0.001,0.2,length=100), seq(0.3,0.4,length=100), seq(0.5,0.6,length=100))
library(gplots)
heatmap.2(deco.hmBB, main = "BCC at day 0 and day 10", margins = c(6,9), trace = "none",
density.info = "none", dendrogram = "none", col = my_palette, breaks = col_breaks,
Colv = "NA")发布于 2017-01-18 22:57:55
如注释所示,使用NAs替换零,如下所示:
deco.hmBB[deco.hmBB == 0] <- NA现在重新运行热图,添加na.color。
heatmap.2(deco.hmBB, main = "BCC at day 0 and day 10", margins = c(6,9),
trace = "none", density.info = "none", dendrogram = "none",
col = my_palette, breaks = col_breaks, Colv = "NA", na.color = "White")https://stackoverflow.com/questions/41560453
复制相似问题