[R] color question

K. Elo m@||||@t@ @end|ng |rom pp@|net@||
Thu Feb 28 08:20:50 CET 2019


Hi!

2019-02-27 22:51 -0500, Aimin Yan wrote:
> I have a question about assigning color based on the value of a
> matrix
> 
> The following is my matrix.
> 
> d
>              lateRT      earlyRT         NAD       ciLAD
> lateRT  1.000000000 0.0000000000 0.006224017 0.001260241
> earlyRT 0.000000000 1.0000000000 0.001425649 0.007418436
> NAD     0.006224017 0.0014256488 1.000000000 0.064653780
> ciLAD   0.001260241 0.0074184361 0.064653780 1.000000000
> LAD     0.006969928 0.0007096344 0.393556636 0.002483941
>                  LAD
> lateRT  0.0069699285
> earlyRT 0.0007096344
> NAD     0.3935566356
> ciLAD   0.0024839407
> LAD     1.0000000000
> 
> I want to use the following function to get heatmap and dendrogram
> 
> > heatmap.2(d,trace="none",margin=c(8, 10))
> 
> but it is hard to use color to make  0.001260241 and 0.0074184361 to
> be
> visualized differently.
> 
> Does anyone know how to adjust color based on these values in this
> matrix?

Have you tried to adapt the attribute "colorTable"?

You have to store the heatmap in an object (say "hm") and the use
"hm$colorTable".

See the examples here: 
https://www.rdocumentation.org/packages/gplots/versions/3.0.1.1/topics/heatmap.2

Also take a look on the documentation.

HTH,
Kimmo



More information about the R-help mailing list