No color key in my heatmap with heatmap2.
1
0
Entering edit mode
3.0 years ago
Riku ▴ 80

Dear all,

I would like to output the heat map with colorkey on top. However, colorkey will not be displayed when using the following command.

heatmap.2(as.matrix(data.z),
          col=colorRampPalette(c("blue3", "white", "red3")),
          scale="none",
          key=TRUE,
          symkey=FALSE,
          density.info="none",
          trace="none",
          cexRow=0.5,
          cexCol = 1,
          Colv = FALSE,
          lmat = rbind(c(0,4,0),c(2,1,0),c(0,3,0)),
          lwid=c(1,10,0.5),lhei=c(1,6,0)
          )

The error message shows the following.

Error in plot.new() : outer margins too large (figure region too small)
In addition: Warning message:
In heatmap.2(as.matrix(data.z), col = colorRampPalette(c("blue3",  :
  Discrepancy: Colv is FALSE, while dendrogram is `both'. Omitting column dendogram.

enter image description here

What problems does my command have?

Thank you

heatmap.2 Rstudio R • 4.5k views
ADD COMMENT
2
Entering edit mode
3.0 years ago
seidel 11k

You have a 0 dimension for your bottom row height. Changing it to: lwid=c(1,10,0.5),lhei=c(3,6,1) gives a valid plot.

However, you're calling 9 positions in lmat, when there are only 4 things to plot, and you're turning off one of the dendrograms, so there's only three things to plot. heatmap.2 plots (1) heat map, (2) row dendrogram, (3) column dendrogram, and (4) key, and it does so like this: matrix(c(4,3,2,1),2,2, byrow=TRUE)

Your call to lmat adds an extra column and row to the layout. You can get essentially the same plot with:

heatmap.2(matrix(rnorm(100), 10, 10)
          , col=colorRampPalette(c("blue3", "white", "red3"))
          , scale="none"
          , key=TRUE
          , symkey=FALSE
          , density.info="none"
          , trace="none"
          , cexRow=0.5
          , cexCol = 1
          , Colv = FALSE
          , lmat=rbind(c(3,4),c(2,1))
)
ADD COMMENT
0
Entering edit mode

Thank you very much! I was able to solved this probem for your advices.

ADD REPLY

Login before adding your answer.

Traffic: 2701 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6