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

Trying to follow the instructions here:

https://bioconductor.org/packages/devel/bioc/vignettes/treeio/inst/doc/Importer.html#need-helps

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 <- read.annotated.nexus("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

phy$annotations[[69]]$length_95%_HPD

I get :

[[1]]

[1] 29.06452

[[2]]

[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:

https://groups.google.com/forum/#!topic/beast-users/Wpq2CU2Y5BQ

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

The tree I am using can be reached here.

https://www.dropbox.com/s/ywtachr6gsd4wcd/bk98_01_11_A7.tre?dl=0

 

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 • 2.7k views
ADD COMMENT
0
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.

ADD REPLY
0
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
  length_0.95_HPD
  <list>         
1 <dbl [2]>      
> d[[69,'length_0.95_HPD']]
[1]  3.813404 18.423332

pls make sure you are using the latest release version.

ADD REPLY
0
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
get.fields(phyA1)

TphyA1 <- get.data(phyA1)
DphyA1<- as.data.frame(TphyA1)

 

Thanks again

ADD REPLY

Login before adding your answer.

Traffic: 633 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6