【问题标题】:How to adjust the color range in heatmap.2如何调整heatmap.2中的颜色范围
【发布时间】:2016-07-17 18:38:20
【问题描述】:

我正在尝试使用 R 语言绘制热图。

在绘制热图图表后,发现我的热图不适合解释,因为颜色键的范围没有调整好。

正如您在下面看到的,与我的数据分布相比,颜色键范围非常长。(它们在零到四之间)。因此,热图中的所有颜色都是绿色的。

如何解决这个问题?

以下是我的代码。 (我试图搜索解决方案,但我没有找到适合我的案例的线程。)

library(gplots)
matrix <- as.matrix(read.delim("bladder",header=FALSE))
hclustfunc <- function(x) hclust(x, method="complete")
distfunc <- function(x) dist(x, method="euclidean")
cl.col <- hclustfunc(distfunc(t(matrix)))
gr.col <- cutree(cl.col, 4)
heatmap.2(as.matrix(matrix),col=greenred(75),dendrogram=c("col"),trace="none",Rowv=FALSE,margins = c(8,16),cexRow=0.60,cexCol=0.8)

【问题讨论】:

  • 请提供复制数据!

标签: r plot heatmap hclust gplots


【解决方案1】:

确保在以下示例中将n 设置为正确的长度:

my_palette <- colorRampPalette(c("red", "blue", "green"))(n = 100)

heatmap.2(as.matrix(matrix), col=my_palette, 
    breaks=colors, density.info="none", trace="none", 
        dendrogram=c("row"), symm=F,symkey=F,symbreaks=T, scale="none")

【讨论】:

    猜你喜欢
    • 2013-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-28
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    相关资源
    最近更新 更多