0

我对 R 中的 pheatmap 函数有 1 个问题,如果有人能帮助我,我将不胜感激。

1) 在做 pheatmaps 时,我总是使用 break 函数来设置我的休息时间。但是,如果某个值超出了确定的中断,则它会自动以白色表示。有谁知道如何将我的休息时间中的值设置为与我的最大值或最小值相同的颜色?这是使用“ALL”库的代码示例:

library(pheatmap)
library(RColorBrewer)
library(ALL)

data("ALL")
expressionData = exprs(ALL)

#setting breaks to 0 to 5 then 5.01 to 10
breaks = c(seq(0, 5, length.out = 101),seq(5.01, 10, length.out = 101))
breaks2 <- breaks

#setting colors
my_palette <- colorRampPalette(c("blue", "white", "red"))(n = 201)

#running pheatmap with 10 first samples
pheatmap(expressionData[1:10, ], color = my_palette, breaks = breaks2)

pheatmap 结果的图像

因为样本 1005_at 的一些值高于我的最高断点 10,所以它们最终是白色的。我如何设置高于 10 的值与值 10 的颜色相同(反之,如果值低于 0,如何将它们设置为与值 0 相同的颜色)?

非常感谢!!!

4

1 回答 1

0

这似乎是一个可能的解决方案:

library(pheatmap)
library(RColorBrewer)
library(ALL)

data("ALL")
expressionData = exprs(ALL)

#setting breaks to 0 to 5 then 5.01 to 10
breaks = c(seq(0, 5, length.out = 101),seq(5.01, 10, length.out = 101))
breaks2 <- breaks

#setting colors
my_palette <- colorRampPalette(c("blue", "white", "red"))(n = 201)

breaks2[length(breaks)] <- max(max(expressionData),max(breaks))
breaks2[1] <- min(min(expressionData),min(breaks))
#running pheatmap with 10 first samples
pheatmap(expressionData[1:10, ], color = my_palette, breaks = breaks2)
于 2017-12-04T03:22:51.877 回答