I used following code to generate a heatmap using heatmap.2 of R. key="F" gets rid of color key at the top. However the plot does not rescale leaving a blank space on the place previously occupied by the colour key. How do I recenter the plot by getting rid of the blank space at the top?
dImp_heatmap <- heatmap.2(dSet_matrix, Rowv=NA, Colv=NA, col = cm.colors(20), dendrogram="none",trace="none", key="F",margins=c(1,8),colsep=c(1:6),rowsep=(1:62),sepwidth=c(0.05,0.05), sepcolor="white", cellnote=round(dSet_matrix,digits=2),notecol="black",notecex=0.7,scale="column")
If you read the documentation for ?heatplot.2
carefully, you'll see at the bottom of the list of arguments the following:
lmat, lhei, lwid visual layout: position matrix, column height, column width. See below for details
And the details are:
This layout can be overriden by specifiying appropriate values for lmat, lwid, and lhei. lmat controls the relative postition of each element, while lwid controls the column width, and lhei controls the row height. See the help page for layout for details on how to use these arguments.
So for example:
data(mtcars)
x <- as.matrix(mtcars)
rc <- rainbow(nrow(x), start=0, end=.3)
cc <- rainbow(ncol(x), start=0, end=.3)
##
## demonstrate the effect of row and column dendrogram options
##
gplots:::heatmap.2(x,key = FALSE,dendrogram = "row",lhei = c(0.05,0.95))
and I imagine the setting lwid
would behave similarly. Although I should add that if you include both dendrograms, then the space in the upper left is necessary to make room for the dendrograms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With