4

这是数据:

set.seed(123)
mat <- matrix(rnorm(5000, 0.5, 0.2), 50)
heatmap (mat)

在此处输入图像描述

mat[mat > 0.05] <- NA
heatmap (mat)

Error in hclustfun(distfun(x)) : 
  NA/NaN/Inf in foreign function call (arg 11)

通过替换为其他值(任意值会有所帮助),但它会欺骗读者,因为它会从相同的比例中选择颜色,这是不正确的。所以我想为那些大于 0.05 的值设置完全不同的颜色。

mat[mat > 0.05] <- 0.1
heatmap (mat)

在此处输入图像描述

4

1 回答 1

4

maybe...

library(gplots)
set.seed(123)
mat <- matrix(rnorm(5000, 0.5, 0.2), 50)
heatmap.2(mat, breaks=c(-1,0.02,0.05,1), col=c("yellow", "red", "blue"), 
# aiming for >0.05 is blue
dendrogram="both", trace="none")

Basically play around with col= and breaks=

looks like:

enter image description here

于 2012-05-13T15:58:59.940 回答