How can I read in BEAST nexus tree with treeio and get all node values
Entering edit mode
sknu003 • 0
Last seen 3.8 years ago

Trying to follow the instructions here:

I want to read in my phylogenetic tree with the 'treeio' package. And get all the values associated with the nodes. Or any other package for that matter.

After having installed 'ips' and 'treeio' and the 'ape' package, and I have set a path to my working directory.

I tried this:

phyA <- read.beast("bk98_01_11_A7.tre", digits = NULL)

But this did not work.

It returned this error:

Error in (i2 + 1):end : argument of length 0


I then tried installing the "OutbreakTools" package.

And I then tried this:

phyA <-"bk98_01_11_A7.tre")

this worked fine. But when I then examining a node (e.g. node number 69 ) in my tree object:

phy <- phyA


I get :


[1] 29.06452


[1] 53.19834

But looking at this value at this node (69) in FigTree I can see the values should be :

3.813 and 18.423

I also had a look here:!topic/beast-users/Wpq2CU2Y5BQ

But could not get any of the suggested approaches to work.

The tree I am using can be reached here.


My input tree might be wrong. But I have no idea to how the file should be instead. Thanks in advance for any help on this.







treeio beast nexus ips OutbreakTools • 1.4k views
Entering edit mode

the last issue is from outbreaktools and/or figtree, you need to open the file with text editor and verify it manually to check whether these program parse the file correctly.


From your msg, treeio fails to parse your file. You can send me the file via email (guangchuangyu AT gmail) and I will look into it.

Entering edit mode

thanks for sending the file.

I have no problem to read the file using treeio package.

> require(treeio)
> phyA <- read.beast("bk98_01_11_A7.tre")
> require(tidytree)
> d <- as_tibble(phyA)
> d[69,'length_0.95_HPD']
# A tibble: 1 x 1
1 <dbl [2]>      
> d[[69,'length_0.95_HPD']]
[1]  3.813404 18.423332

pls make sure you are using the latest release version.

Entering edit mode

Brilliant. Yes. This did it. I was running R v3.5.1. But your instructions in your reply worked. My next problem was to get all the node information in to a data frame. I had never before heard of tibbles. Once I looked up tibble on the internet I could easily prepare a data frame , that I am more familiar with.

To get the tibble turned into a data frame I did this:

phyA1 <- phyA

TphyA1 <-


Thanks again


Login before adding your answer.

Traffic: 211 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6