This is a test version of Biostars. For the public version, visit https://www.biostars.org.
plotting trees in R: node labels from nexus tree files

Hi,

I am trying to plot a phylogeny from RevBayes in R.

The trees are in nexus format. For some reason, node labels do not import when I use ape::read.nexus(). When checking the phylo object, it shows that branch lengths have been imported, but no node labels. I am able to see the node labels in Figtree. I've tried exporting to Newick format in Figtree, but then node labels are lost.

Here's the phylo object:

Phylogenetic tree with 46 tips and 45 internal nodes.

Tip labels: Tadh_1, Tadh_20, Tadh_25, Tadh_26, Tadh_27, Tadh_18, ...

Rooted; includes branch lengths.

Here's a fragment of the tree in my nexus file:

Begin trees; tree TREE1 = [&R](((((((((Tadh_1[&index=13]:0.315435,Tadh_20[&index=8]:0.315435)[&index=47,posterior=0.052038,age_95%_HPD={0.229588,0.415859}]:0.028293,Tadh_25[&index=11]:0.343728)[&index=48,posterior=0.017375,age_95%_HPD={0.26249,0.436248}]:0.040193, ... etc.

thanks for any help!

revbayes nexus ape r ggtree

To clarify, the node labels I am after are the posterior probabilities ("posterior").

1 answer

The read.beast() function in the treeio package should be able to parse the file and then you can use the ggtree package to visualize the tree with or without associated data (e.g. posterior values).

Thank you! I'll give that a try. Also, thanks for making ggtree! I love that package.

Log in to answer this question.