我有一个使用gplots
构建的工作热图,如下所示:
heatmap.2(as.matrix(matrix1),cellnote=as.matrix(matrix1),
notecol="black",margins =c(9,6),trace="none",density.info="none",
col=my_palette,Rowv=NA,Colv=NA,dendrogram="none",scale="row")
matrix1
中的基础数据如下所示:
A AA AAA BBB CASH
CASH 0 0 0 0
JSUB 0.22171 0 0 2.20712
SECR 2.92828 1.97112 3.53786 0.91444
SENR 18.86672 11.53339 15.06844 21.57709
SSEN 5.707 1.96225 0.57815 2.93462
SSUB 0.36507 0.07968 0 0.44985
SUB 1.0539 0 0 2.37103
T1 0 0 0 0.56024
T2 1.87901 0 0 3.00718
UT2 0 0 0 0.15787
我的matrix1
是使用cast
包创建为带reshape
函数的数据透视表,包含许多零。每当我的矩阵中的值为零时,我就不想显示' cellnote',因为这只会混淆热图。
谢谢!
答案 0 :(得分:1)
对我而言,它只是用新的矩阵用NA代替零,并将其作为参数传递给cellnote
。
matrix2 <- as.matrix(matrix1)
matrix2[matrix2 == 0] <- NA
使用matrix2
heatmap.2(as.matrix(matrix1),cellnote=matrix2,
notecol="black",margins =c(9,6),trace="none",density.info="none",
col=my_palette,Rowv=NA,Colv=NA,dendrogram="none",scale="row")
(顺便说一句,你没有给my_palette
,所以我把它放到了这个例子中。)