[BioC] cexRow problem

James W. MacDonald jmacdon at uw.edu
Wed Oct 3 15:46:49 CEST 2012

Hi Alyaa,

On 10/2/2012 6:59 PM, Alyaa Mahmoud wrote:
> Hi All
> I am trying to generate a heatmap for a matrix of 360 rows and 11 columns,
> I need the row labels to be readable from within the heatmap by zooming or
> so. I use heatmap.2 function but when I decrease cexRow to any value lower
> than 0.06, the labels just disappear, i.e. they don't get any smaller. I
> also tried the margins argument within heatmap.2 function but this didn't
> solve the problem.
> Any help with this regards ??

I have rarely found the need to set the cexCol argument, and have found 
that the better idea is to make the resulting image of the right 
dimensions. I assume here that you are creating a heatmap with lots of 
rows, and comparatively speaking, much fewer columns. If you don't 
specify the dimensions of the output, then you will get a square-ish 
heatmap with really thin rows that are hard to label.

If instead, you specify that the heatmap will be a really tall thin 
object, then you get something closer to what you are likely interested 
in. Try something like this:

pdf("tmp.pdf", width = 8, height = 200) ## you may need to play with the 
height arg
heatmap.2(as.matrix(bb), scale="row", key=TRUE, symkey=FALSE, 
density.info="none", trace="none", cexCol=0.2, dendrogram="both", 
Rowv=rowv, col=brewer.pal(9,"BuPu"))

You can use jpeg(), png(), etc, but note that those are raster graphics 
that won't scale without becoming pixellated, whereas pdfs are vector 
graphics that will scale well. If you are on windows you might consider 
win.metafile() as well, but in my experience the column labels get 
mis-placed more often than not (being put right on top of the lower 
portion of the heatmap). So I tend to stick with pdfs.

If you need something square-ish for e.g., a publication, then the rows 
won't be legible anyway. In that case it seems to me that most people 
just forgo row labels altogether.



> heatmap.2(as.matrix(bb), scale="row", key=TRUE, symkey=FALSE,
> density.info="none",
> trace="none", cexRow=0.06, cexCol=0.2, dendrogram="both", Rowv=rowv,
> col=brewer.pal(9,"BuPu"))
> Thanks a lot
> Alyaa

James W. MacDonald, M.S.
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099

More information about the Bioconductor mailing list