如何更改R

时间:2017-12-04 02:58:17

标签: r pheatmap

我对R中的pheatmap函数有一个问题,如果有人能帮助我,我将非常感谢。

1)在做pheatmap时,我总是使用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)

image of the pheatmap result

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

非常感谢!!!

1 个答案:

答案 0 :(得分: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)
相关问题