Dear Pedro.

The common way to accomplish this is using /ape::nodelabels/; however, 
in Chapter 13 of my recent book 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
with Luke Harmon we show how to code it yourself pretty easily. I also 
just posted a solution that you might find useful on my blog: 
http://blog.phytools.org/2023/08/coloring-nodes-by-bootstrap-or-bayesian.html.

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/
Book: Phylogenetic Comparative Methods in R 
<https://press.princeton.edu/books/phylogenetic-comparative-methods-in-r> 
(/Princeton University Press/, 2022)


On 8/10/2023 11:11 AM, Pedro Taucce wrote:
> [You don't often get email frompedrotau...@gmail.com. Learn why this is 
> important athttps://aka.ms/LearnAboutSenderIdentification  ]
>
> CAUTION: EXTERNAL SENDER
>
> Dear all,
>
> I want to plot an ultrametric BEAST2 tree with circles in the nodes colored
> by posterior probability: > 0.95 black, between 0.5 and 0.95 gray and 0.5
> and below no circle (or white). Is that possible? I have tried several
> packages and solutions and the more close solution I figured out is:
>
> # Load the required libraries
> library(treeio)
> library(phytools)
>
> # Set the working directory
> setwd("~/Documents/Anolis_Ana/BEAST2/")
>
> # Read the tree from the file
> my_tree <- read.beast("anolis_ND2.tre")
> posterior <- my_tree$posterior
>
> # Define colors based on posterior probabilities
> colors <- ifelse(posterior > 0.95, "black",
>                   ifelse(posterior > 0.5, "darkgray", "white"))
> # Assign colors to tree nodes
> my_tree$node.color <- colors
>
> # Plot the tree with custom node colors
> plot(my_tree,direction="upwards",show.tip.label = F, node.color = colors)
>
> The problem is it colors the branches instead of the nodes. Any ideas?
>
> Thank you very much!
>
> Pedro
> -----
> Dr. Pedro P. G. Taucce
> Postdoctoral Researcher (CNPq - PDJ)
> National Institute of Amazonian Research (INPA)
> Av. André Araújo 2936, Petrópolis
> CEP 69.067-375 Manaus, AM
>
> http://www.pedrotaucce.org/
> Lattes<http://lattes.cnpq.br/6010051338306653>  | LinkedIn
> <http://linkedin.com/in/pedrotaucce>  | ResearchGate
> <https://www.researchgate.net/profile/Pedro-Taucce>
>
> Associate Editor, *The Herpetological Journal
> <https://www.thebhs.org/publications/the-herpetological-journal>*
>
> Subject Editor, *Zoosystematics and Evolution<https://zse.pensoft.net/>*
>
> Subject Editor, *Neotropical Biology and Conservation
> <https://neotropical.pensoft.net/>*
>
>          [[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 athttp://www.mail-archive.com/r-sig-phylo@r-project.org/
        [[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/

Reply via email to