Hi R users,

I'm a quite extensive user of the heatmap() function, and as many others
i'm frequently frustrated by its fixed square width / height ratio. Here is
a typical example :

     dev.new()
     heatmap(matrix(rnorm(1200), nrow=10))

I have a non square matrix to plot with heatmap, as there are many more
columns than rows, row labels are larger than necessary but column labels
can't be read (this is quite common in transcriptomics, where there are
many more genes than samples studied). With a classical plot, this could be
fixed using a non square device area :

     dev.new(width=10, height=5)
     heatmap(matrix(rnorm(1200), nrow=10))

But as can be seen, heatmap don't make profit of it and leave empty room on
each side. To get a readable figure, the user is requested to use a very
large square device area (export to file becomes mandatory when the screen
is not large enough), and thus to accommodate with very high rows and tiny
columns.

This flaw led several useRs to develop alternative functions in external
packages :
http://bioinformatics.mdanderson.org/Software/OOMPA/ClassDiscovery/html/aspectHeatmap.html
http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/gplots/html/heatmap.2.html

But after a quick look at the "stats" package sources, this seems quite
easy to fix, without breaking backward compatibility :


[ src/library/stats/R/dendrogram.R ]

- line 689 : add "width=1" and "height=1" as arguments to heatmap()
- line 768 : lwid <- c(if(doRdend) 1 else 0.05, 4)
                lwid <- c(if(doRdend) 1 else 0.05, width*4)
- line 769 : lhei <- c((if(doCdend) 1 else 0.05) + if(!is.null(main)) 0.2
else 0, 4)
                lhei <- c((if(doCdend) 1 else 0.05) + if(!is.null(main))
0.2 else 0, height*4)


As the default values are 1, default behavior does not change and lead to
square ratio. Changing "width" from 1 to 2 would lead to a figure with
image() call roughly twice wider than high, and so on.

Smarter default values could also be computed from the matrix size, e.g. :
width = log(dim(x)[2] / dim(x)[1])
height = 1

As can be seen the two arguments could be replaced by a single "ratio"
argument, as the function is using relative layout values ("width = 0.5 /
height = 1" and "width = 1 / height = 2" have the same effect).


So, is there a chance to see this behavior in a future R version or not ?


Regards,
Sylvain Mareschal

	[[alternative HTML version deleted]]

