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

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 at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to