Re: [R-sig-phylo] plot heatmap at nodes

2018-08-30 Thread Emmanuel Paradis
Another possibility (maybe more flexible) is to get the coordinates of 
the nodes and then call rect(). Something like:


tr <- rcoal(10)
plot(tr, "p", FALSE)
lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
x <- lastPP$xx[-(1:lastPP$Ntip)]
y <- lastPP$yy[-(1:lastPP$Ntip)]
s <- 0.3
par(xpd = TRUE)
for (h in s * c(-1.5, -.5, .5))
  for (v in s * c(-1.5, -.5, .5))
rect(x + h, y + v, x + h + s, y + v + s, col=sample(colors(), 9))

with 's' the size of each cell of the heatmap, and the vectors 'h' and 
'v' are calculated for a 3x3 matrix, so this can be generalized to 
different dimensions (even non-square). The options of rect() can be 
used (border, ...)


par(xpd = TRUE) is to make the heatmap at the root completely visible.

Best,

Emmanuel

Le 30/08/2018 à 12:45, Emmanuel Paradis a écrit :

Hi Jacob,

It is possible to call nodelabels() several times to do something 
similar to what you want by playing with the adj argument which is 
c(0.5, 0.5) by default (ie, the label is centered on the node). You can 
try this:


tr <- rcoal(5)
plot(tr, "p", FALSE)
for (h in c(0.4, 0.5, 0.6))
   for (v in c(0.4, 0.5, 0.6))
     nodelabels(pch=15, col=sample(colors(), size=1), cex=2, adj=c(h, v))

The difficulty is to find the 1st and 3rd values of h (horizontal) and v 
(vertical) and this will depend on the size of the device (and the value 
of cex of course). Maybe there's a way to automate these calculations.


Best,

Emmanuel

Le 30/08/2018 à 00:12, Jacob Berv a écrit :

Dear R-sig-phylo,

Does there exist a function to plot heatmaps at internal nodes of a 
tree? For example, to illustrate support values from different 
phylogenetic analyses — ie given a set of 3x3 matricies of support 
values for particular nodes.


It seems like there may be a partial (and definitely workable) 
solution here, using ggtree— 
https://rgriff23.github.io/2017/05/11/primate-phylogeny-ggtree.html 
, 
if such heatmaps are saved as raster images (about 1/2 way down). This 
may be the easiest solution, but it would be preferable to keep 
everything in vector format and all in R.


I guess I could do this by calling image() for the individual heatmaps 
and then just linking them up to nodes of interest in illustrator (but 
that feels like cheating).


Jake



[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at 
http://www.mail-archive.com/r-sig-phylo@r-project.org/



Pour nous remonter une erreur de filtrage, veuillez vous rendre ici : 
http://f.security-mail.net/408vx1yEbQu





___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at 
http://www.mail-archive.com/r-sig-phylo@r-project.org/








___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] plot heatmap at nodes

2018-08-30 Thread Jacob Berv
Ah, not really. I am thinking more of an actual matrix, where matrix entries 
represent support values, and are colored proportionally. Ie - something like:

image(t(matrix(data=c(95, 60,75,85), nrow=2, ncol=2)), col=heat.colors(4), 
yaxt='n', xaxt='n')

Jake


> On Aug 29, 2018, at 8:06 PM, Liam J. Revell  wrote:
> 
> Hi Jake. Can you draw a clearer picture of what you'd like to do? Would it 
> look something like the error bars that phytools can compute for contMap 
> object? (e.g., 
> http://blog.phytools.org/2017/02/function-to-add-error-bars-to-contmap.html)
> 
> All the best, Liam
> 
> Liam J. Revell
> Associate Professor, University of Massachusetts Boston
> Profesor Asistente, Universidad Católica de la Ssma Concepción
> web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org
> 
> On 8/29/2018 7:12 PM, Jacob Berv wrote:
>> Dear R-sig-phylo,
>> Does there exist a function to plot heatmaps at internal nodes of a tree? 
>> For example, to illustrate support values from different phylogenetic 
>> analyses — ie given a set of 3x3 matricies of support values for particular 
>> nodes.
>> It seems like there may be a partial (and definitely workable) solution 
>> here, using ggtree— 
>> https://rgriff23.github.io/2017/05/11/primate-phylogeny-ggtree.html 
>> , if 
>> such heatmaps are saved as raster images (about 1/2 way down). This may be 
>> the easiest solution, but it would be preferable to keep everything in 
>> vector format and all in R.
>> I guess I could do this by calling image() for the individual heatmaps and 
>> then just linking them up to nodes of interest in illustrator (but that 
>> feels like cheating).
>> Jake
>>  [[alternative HTML version deleted]]
>> ___
>> R-sig-phylo mailing list - R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] plot heatmap at nodes

2018-08-30 Thread Emmanuel Paradis

Hi Jacob,

It is possible to call nodelabels() several times to do something 
similar to what you want by playing with the adj argument which is 
c(0.5, 0.5) by default (ie, the label is centered on the node). You can 
try this:


tr <- rcoal(5)
plot(tr, "p", FALSE)
for (h in c(0.4, 0.5, 0.6))
  for (v in c(0.4, 0.5, 0.6))
nodelabels(pch=15, col=sample(colors(), size=1), cex=2, adj=c(h, v))

The difficulty is to find the 1st and 3rd values of h (horizontal) and v 
(vertical) and this will depend on the size of the device (and the value 
of cex of course). Maybe there's a way to automate these calculations.


Best,

Emmanuel

Le 30/08/2018 à 00:12, Jacob Berv a écrit :

Dear R-sig-phylo,

Does there exist a function to plot heatmaps at internal nodes of a tree? For 
example, to illustrate support values from different phylogenetic analyses — ie 
given a set of 3x3 matricies of support values for particular nodes.

It seems like there may be a partial (and definitely workable) solution here, using 
ggtree— https://rgriff23.github.io/2017/05/11/primate-phylogeny-ggtree.html 
, if such 
heatmaps are saved as raster images (about 1/2 way down). This may be the easiest 
solution, but it would be preferable to keep everything in vector format and all in R.

I guess I could do this by calling image() for the individual heatmaps and then 
just linking them up to nodes of interest in illustrator (but that feels like 
cheating).

Jake



[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Pour nous remonter une erreur de filtrage, veuillez vous rendre ici : 
http://f.security-mail.net/408vx1yEbQu




___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/