r - draw two heatmap with the same cell size -
i drawing 2 heatmaps using heatmap.2 separately different number of rows. there way set output of plots actual cell size same between 2 heatmaps?
library(gplots) data(mtcars) x<-as.matrix(mtcars) ### heatmap has 32 rows heatmap.2(x,key=f) x1<-x[1:10,] ### heatmap has 10 rows heatmap.2(x1,key=f)
this can done, albeit in of kludgy way, using lmat
, lhei
, , lwid
arguments of heatmap.2
. arguments passed layout
, lay out various parts of image.
library(gplots) data(mtcars) x <- as.matrix(mtcars) ### 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 can see, matrix argument gives matrix looks like:
[,1] [,2] [1,] 4 3 [2,] 2 1
the heatmap first thing plotted, followed row , column dendrogram. arguments lhei
, lwid
give relative size of each of layout column , rows described in lmat
. creativity, lay out panels allow move things , down saw fit. proof of concept, did following, scales lhei
10/32
.
x1<-x[1:10,] ### 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:
Comments
Post a Comment