Fine tuning heatmap.2 graphics
2
0
Entering edit mode
Marc Saric ▴ 70
@marc-saric-1645
Last seen 5.2 years ago
Dear all, I like to use heatmap.2 from the gplots library package to automatically plot heatmaps from microarray data. Things work fine so far, but two problems remain: 1. Depending on the amount of data to be displayed, the fontsize of the labels changes dynamically (as it should) and with that, the margin-space required to print the labels changes also (leading to truncated labels sometimes). This can be set manually with margin <- c(x,y); for both x and y axis labels margins. Is there an easy way to compute the required margin size dynamically from -say- the lenght of the longest label-string? 2. Plotting with heatmap.2 in the X11 device gives a plot, in which all the coloured rectangles are drawn without visible separating border between them. When plotting as "pngalpha" with the bitmap device, you can see separating bright borderlines, which -due to the antialiasing- are only partly visible (i.e. some lines are there, some have been removed by the antialiasing). Is there any option to remove this borders when plotting with bitmap and "pngalpha"? I have tried with sepwidth = c(0.0,0.0), sepcolor = "black", but this does not have any visible effect. Thanks in advance. -- Bye, Marc Saric
Microarray Microarray • 17k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
On 3/9/06 6:41 AM, "Marc Saric" <marc.saric at="" gmx.de=""> wrote: > Dear all, > > I like to use heatmap.2 from the gplots library package to automatically > plot heatmaps from microarray data. > > Things work fine so far, but two problems remain: > > 1. Depending on the amount of data to be displayed, the fontsize of the > labels changes dynamically (as it should) and with that, the > margin-space required to print the labels changes also (leading to > truncated labels sometimes). > > This can be set manually with > > margin <- c(x,y); > > for both x and y axis labels margins. > > Is there an easy way to compute the required margin size dynamically > from -say- the lenght of the longest label-string? Not sure here. I imagine it is possible, but I don't know how to do it. > 2. Plotting with heatmap.2 in the X11 device gives a plot, in which all > the coloured rectangles are drawn without visible separating border > between them. > > When plotting as "pngalpha" with the bitmap device, you can see > separating bright borderlines, which -due to the antialiasing- are only > partly visible (i.e. some lines are there, some have been removed by the > antialiasing). > > Is there any option to remove this borders when plotting with bitmap and > "pngalpha"? > > I have tried with > > sepwidth = c(0.0,0.0), > sepcolor = "black", > > but this does not have any visible effect. If I remember, heatmap.2 doesn't actually put any separators between the columns/rows by default. (You can glance at the code to check.) This happens on some viewers with some formats, but the view that you see with the X11 device is the one that heatmap.2 is actually drawing, I think, so there isn't a way to eliminate this effect with those other devices. Try pdf or ps devices and see what you get. Sean
ADD COMMENT
0
Entering edit mode
Wittner, Ben ▴ 290
@wittner-ben-1031
Last seen 8.9 years ago
USA/Boston/Mass General Hospital
> -----Original Message----- > From: bioconductor-bounces at stat.math.ethz.ch [mailto:bioconductor- > bounces at stat.math.ethz.ch] On Behalf Of Marc Saric > Sent: Thursday, March 09, 2006 6:41 AM > To: bioconductor at stat.math.ethz.ch > Subject: [BioC] Fine tuning heatmap.2 graphics > > Dear all, > > I like to use heatmap.2 from the gplots library package to automatically > plot heatmaps from microarray data. > > Things work fine so far, but two problems remain: > > 1. Depending on the amount of data to be displayed, the fontsize of the > labels changes dynamically (as it should) and with that, the > margin-space required to print the labels changes also (leading to > truncated labels sometimes). > > This can be set manually with > > margin <- c(x,y); > > for both x and y axis labels margins. > > Is there an easy way to compute the required margin size dynamically > from -say- the lenght of the longest label-string? I have used the following code for setting margins for heatmap() (not heatmap2()): margin.factor <- 12 marg <- max(5, min(20, ceiling(margin.factor*max.nchar/ncol(expr3)))) margins <- c(marg, marg) where max.nchar is the max length of column label and expr3 is the matrix being displayed. It worked okay but not completely satisfactorily. BTW, what is the advantage of heatmap2() over heatmap()? Does anyone know of a heatmap()-like function that can add multiple rows of column colors (each row corresponding, say, to various phenotypic parameters) such as can be done with dChip? Thanks. -Ben
ADD COMMENT
0
Entering edit mode
Wittner, Ben, Ph.D. wrote: > I have used the following code for setting margins for heatmap() (not > heatmap2()): > > margin.factor <- 12 > marg <- max(5, min(20, ceiling(margin.factor*max.nchar/ncol(expr3)))) > margins <- c(marg, marg) Thanks, will try. > where max.nchar is the max length of column label and expr3 is the > matrix being displayed. It worked okay but not completely satisfactorily. > BTW, what is the advantage of heatmap2() over heatmap()? Mostly that you get more options to tweak the graphics, like a color- key and some more color-schemas out of the box. > Does anyone know of a heatmap()-like function that can add multiple rows of > column colors (each row corresponding, say, to various phenotypic parameters) > such as can be done with dChip? Not that I would know. -- Bye, Marc Saric
ADD REPLY
0
Entering edit mode
Hi, In a similar vein, is there a simple (?) way of manually setting the height/width of the heatmap rows/columns per se, not just change font size scaling of labels/legends, i.e. for non-symmetrical matrices? Thanks for any suggestions, Cheers, al > -----Original Message----- > From: bioconductor-bounces at stat.math.ethz.ch > [mailto:bioconductor-bounces at stat.math.ethz.ch] On Behalf Of > Marc Saric > Sent: 09 March 2006 15:19 > To: Wittner, Ben, Ph.D. > Cc: bioconductor at stat.math.ethz.ch > Subject: Re: [BioC] Fine tuning heatmap.2 graphics > > > Wittner, Ben, Ph.D. wrote: > > > I have used the following code for setting margins for > heatmap() (not > > heatmap2()): > > > > margin.factor <- 12 > > marg <- max(5, min(20, > ceiling(margin.factor*max.nchar/ncol(expr3)))) > > margins <- c(marg, marg) > > Thanks, will try. > > > > where max.nchar is the max length of column label and expr3 is the > > matrix being displayed. It worked okay but not completely > > satisfactorily. > > > BTW, what is the advantage of heatmap2() over heatmap()? > > Mostly that you get more options to tweak the graphics, like > a color-key and some more color-schemas out of the box. > > > > Does anyone know of a heatmap()-like function that can add multiple > > rows of column colors (each row corresponding, say, to various > > phenotypic parameters) such as can be done with dChip? > > Not that I would know. > > > -- > Bye, > > Marc Saric > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/biocondu> ctor >
ADD REPLY
0
Entering edit mode
On 3/9/06 10:30 AM, "Al Ivens" <alicat at="" sanger.ac.uk=""> wrote: > Hi, > > In a similar vein, is there a simple (?) way of manually setting the > height/width of the heatmap rows/columns per se, not just change font > size scaling of labels/legends, i.e. for non-symmetrical matrices? Are you using heatmap or heatmap.2? Heatmap.2 defaults to not forcing a square image. Heatmap, though, defaults to a square image. Is this to what you are referring? Sean
ADD REPLY
0
Entering edit mode
Hi Sean, Thanks for this. > Are you using heatmap or heatmap.2? Heatmap.2 defaults to > not forcing a square image. Heatmap, though, defaults to a > square image. Is this to what you are referring? Sort of! Most of the "problems" stem from saving the plot out to a png, but it seems one can get around this by specifying "height" as an appropriate direct multiple of the matrix rows, and letting "width" sort itself out. Probably a fairly esoteric query, but is there a way of controlling the aspect ratio of the cells that make up the map, i.e. do they HAVE to be rectangles? Cheers and thanks, a > > Sean > >
ADD REPLY
0
Entering edit mode
On 3/10/06 8:58 AM, "Al Ivens" <alicat at="" sanger.ac.uk=""> wrote: > Hi Sean, > > Thanks for this. > >> Are you using heatmap or heatmap.2? Heatmap.2 defaults to >> not forcing a square image. Heatmap, though, defaults to a >> square image. Is this to what you are referring? > > Sort of! Most of the "problems" stem from saving the plot out to a png, > but it seems one can get around this by specifying "height" as an > appropriate direct multiple of the matrix rows, and letting "width" sort > itself out. > > Probably a fairly esoteric query, but is there a way of controlling the > aspect ratio of the cells that make up the map, i.e. do they HAVE to be > rectangles? You could probably make a wrapper that includes a calculation of the approximate size of the resulting image (assuming that you want approximately square cells) given the number of genes/samples, do the appropriate png() or pdf() command with the calculated height/width specified, then do the heatmap[.2]() command. Sean
ADD REPLY
0
Entering edit mode
> BTW, what is the advantage of heatmap2() over heatmap()? heatmap.2 can show a color key (use key=True) and density information histograms. The color key is probably not so important if you are letting the heatmap function scale your data - see also option scale="none" > Does anyone know of a heatmap()-like function that can add multiple rows of > column colors (each row corresponding, say, to various phenotypic parameters) > such as can be done with dChip? No, but its a question I had been wondering about too. Peter
ADD REPLY
0
Entering edit mode
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/bioconductor/attachments/20060309/ f4d7fbec/attachment.pl
ADD REPLY
0
Entering edit mode
> BTW, what is the advantage of heatmap2() over heatmap()? heatmap.2 can show a color key (use key=True) and density information histograms. The color key is probably not so important if you are letting the heatmap function scale your data - see also option scale="none" > Does anyone know of a heatmap()-like function that can add multiple rows of > column colors (each row corresponding, say, to various phenotypic parameters) > such as can be done with dChip? No, but its a question I had been wondering about too. Peter
ADD REPLY

Login before adding your answer.

Traffic: 707 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6