This can be done, albeit in a something of a kludgy way, by using the lmat
, lhei
, and lwid
arguments of heatmap.2
. This arguments get passed to layout
and lay out the various parts of the image.
library(gplots)
data(mtcars)
x <- as.matrix(mtcars)
### this heatmap has 32 rows
heatmap.2(x = x,
key = F,
lmat = matrix(c(4,2,3,1),
nrow=2,
ncol=2),
lhei = c(0.1,0.9),
lwid = c(0.3,0.7))
As you can see, the matrix argument gives a matrix that looks like:
[,1] [,2]
[1,] 4 3
[2,] 2 1
The heatmap is the first thing plotted, followed by the row and then the column dendrogram. The arguments to lhei
and lwid
give the relative size of each of the layout column and rows described in lmat
. With some creativity, you could lay out the panels to allow you to move things up and down as you saw fit. As a proof of concept, I just did the following, which scales lhei
by 10/32
.
x1<-x[1:10,]
### this heatmap has 10 rows
heatmap.2(x = x1,
key = F,
lmat = matrix(c(4,2,3,1),
nrow=2,
ncol=2),
lhei = c(1-0.9*(10/32),0.9*(10/32)),
lwid = c(0.3,0.7))
Before:

After:
