您需要将断点设置为 -2 和 +2,并在两者之间创建渐变。您还需要将颜色设置为小于最小期望值和大于最大期望值。往下看;
library(pheatmap)
colors <- c(min(mFilt_annot_sort_matrix),seq(-2,2,by=0.01),max(mFilt_annot_sort_matrix))
my_palette <- c("green",colorRampPalette(colors = c("green", "black", "red"))
(n = length(colors)-3), "red")
pheatmap(mFilt_annot_sort_matrix, color = my_palette, breaks = colors, scale =
"none", cluster_rows = F, cluster_cols = F, margin = c(5,5))
使用普通数据的示例;
Using rnorm.within https://gist.github.com/tomhopper/19f07fc96db8d149b24f函数我制作以下数据集:
#V1 is random between -4 and 4
#V2 is less than -2
#V3 is greater than 2
df <- data.frame(cbind(rnorm.within(1000, -4, 4)
,rnorm.within(1000,-4,-3), rnorm.within(1000,3,4)))
并应用上面的过程(相同的刹车和调色板)来制作热图将得到:
pheatmap(df, color = my_palette, breaks = colors, scale =
"none", cluster_rows = F, cluster_cols = F, margin = c(5,5))