Witold E Wolski
2013-Aug-06 11:27 UTC
[R] breaks argument in heatmap.2 doesn't do what it should I think
I do set the breaks parameter in heatmap.2
I would expect that the color.key and the histogram (the thing in the
top left of the plot) are aligned.
Just that everyone can reproduce the problem:
mypalette<-brewer.pal(11,"RdYlBu")
ddd <- rnorm(400,0,0.1)
mdd <- matrix(ddd,ncol=50)
hm <- heatmap.2(mdd,col=mypalette,scale="row") #this is used to
produce the breaks, (and here it works fine)
mdd <- t(scale(t(mdd)))
heatmap.2(mdd,col=mypalette,scale="none",breaks=hm$breaks)
# take a look and you will see that the colors are not aligned with the breaks
although the documentation states
breaks: (optional) Either a numeric vector indicating the splitting
points for binning ?x? into colors, or a integer number of
break points to be used, in which case the break points will
be spaced equally between ?min(x)? and ?max(x)?.
--
Witold Eryk Wolski
Adams, Jean
2013-Aug-06 12:35 UTC
[R] breaks argument in heatmap.2 doesn't do what it should I think
If you look at the help for heatmap.2 (in the gplots package) you will see
the following explanation for breaks
# mapping data to colors
breaks,
symbreaks=min(x < 0, na.rm=TRUE) || scale!="none",
If you run your code with the second call to the heatmap.2() function with
the argument scale="row" instead of scale="none" the colors
are aligned as
in your first call to heatmap.2().
mdd <- t(scale(t(mdd)))
heatmap.2(mdd,col=mypalette, scale="row", breaks=hm$breaks)
Does that help?
Jean
On Tue, Aug 6, 2013 at 6:27 AM, Witold E Wolski <wewolski@gmail.com>
wrote:
> I do set the breaks parameter in heatmap.2
> I would expect that the color.key and the histogram (the thing in the
> top left of the plot) are aligned.
> Just that everyone can reproduce the problem:
>
>
> mypalette<-brewer.pal(11,"RdYlBu")
> ddd <- rnorm(400,0,0.1)
> mdd <- matrix(ddd,ncol=50)
> hm <- heatmap.2(mdd,col=mypalette,scale="row") #this is used
to
> produce the breaks, (and here it works fine)
>
> mdd <- t(scale(t(mdd)))
> heatmap.2(mdd,col=mypalette,scale="none",breaks=hm$breaks)
>
> # take a look and you will see that the colors are not aligned with the
> breaks
> although the documentation states
> breaks: (optional) Either a numeric vector indicating the splitting
> points for binning ‘x’ into colors, or a integer number of
> break points to be used, in which case the break points will
> be spaced equally between ‘min(x)’ and ‘max(x)’.
>
>
>
> --
> Witold Eryk Wolski
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]