reading BEAST output trees into R

5,009 views
Skip to first unread message

Jacob Berv

unread,
Jan 24, 2015, 7:48:02 PM1/24/15
to beast...@googlegroups.com
Hi all,
What do people use to read the nexus/beast formatted tree output from beast into R? the ape read.nexus and read.tree functions result in an "Error in start:end : NA/NaN argument." 

I refer to the raw BEAST output - ie the posterior distribution of trees, not the treeannotator output. I want to randomly subsample the posterior distribution using the function described here:


But I can't get R to read the BEAST output.

Any ideas?

Jake

Jacob Berv

unread,
Jan 24, 2015, 7:48:28 PM1/24/15
to beast...@googlegroups.com
I've also tried the read.beast function in the phyloch package and I get the same error. 
Jake

Santiago Sánchez

unread,
Jan 25, 2015, 9:15:29 AM1/25/15
to beast...@googlegroups.com
Hi Jacob,

Usually, read.nexus() can read BEAST annotated trees without a problem. read.beast() is failing because it uses the read.nexus() function internally. My guess is that there is something wrong with the tree structure its self. Does FigTree open your file without error? If it does, try exporting the tree as nexus or phylip, and try reading these files again with read.nexus() or read.tree(). Does your tree have negative branch lengths? Something else that you can try is summarizing your tree again with the heights = "ca" option.

Hope this helps,
Santiago

--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users...@googlegroups.com.
To post to this group, send email to beast...@googlegroups.com.
Visit this group at http://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.



--
Santiago Sánchez-Ramírez
Department of Ecology and Evolutionary Biology, University of Toronto
Department of Natural History (Mycology), Royal Ontario Museum
100 Queen's Park
Toronto, ON
M5S 2C6
Canada

Jacob Berv

unread,
Jan 26, 2015, 11:25:24 AM1/26/15
to beast...@googlegroups.com
Hi Santiago - 
It turned out that read.nexus() couldn't parse the files because they did not terminate with the 'End;' output (the runs were stopped prematurely). I was able to get them to load into R using read.nexus() but then I learned that read.nexus() doesn't parse most of the branch info that beast writes to the newick format - so I ended up writing a python script that does what I want without losing any of the branch data.

Jake

r.j.c.bi...@rug.nl

unread,
Aug 3, 2016, 4:19:25 AM8/3/16
to beast-users
> But I can't get R to read the BEAST output. Any ideas?
To parse the .trees files to obtain a list of phylogenies (those in the posterior), I currently use the `beast2out.read.trees` function from the https://github.com/olli0601/rBEAST package.

A package with the same functionality is https://github.com/beast-dev/RBeast , but I have not checked that one out yet.


mira...@umn.edu

unread,
Aug 5, 2016, 8:28:41 PM8/5/16
to beast-users
Jake, did you figure it out? I use Phyloch in R.

Hernán


On Saturday, January 24, 2015 at 7:48:02 PM UTC-5, Jacob Berv wrote:

Patrick Strutzenberger

unread,
Aug 6, 2016, 2:15:01 PM8/6/16
to beast...@googlegroups.com
My preferred way is 'read.annotated.nexus' in the ‘OutbreakTools’ package.

cheers
Patrick

--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users+unsubscribe@googlegroups.com.

To post to this group, send email to beast...@googlegroups.com.
Message has been deleted

r.j.c.bi...@rug.nl

unread,
Apr 13, 2018, 8:45:44 AM4/13/18
to beast-users
For BEAST, treeio's 'read.beast' function appears robust.
For BEAST2, tracerer supports reading all the different BEAST2 output files.

Santiago Sánchez

unread,
Apr 13, 2018, 8:54:43 AM4/13/18
to beast...@googlegroups.com
You can also checkout 'read.beast.annot' from: https://github.com/santiagosnchez/rBt

It has some added features, like edge index ordering, to plot and annotate you trees over branches instead of nodes.
There are other useful features, like potting HPD bars on nodes.

You will need to install the package using: 

library(devtools)
install_github("santiagosnchez/rBt")




On Fri, Apr 13, 2018 at 8:45 AM <r.j.c.bi...@rug.nl> wrote:
For BEAST, treeio's 'read.beast' function appears robust.
For BEAST2, tracerer supports reading all the different BEAST2 output files.

--
You received this message because you are subscribed to the Google Groups "beast-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beast-users...@googlegroups.com.

To post to this group, send email to beast...@googlegroups.com.
Visit this group at https://groups.google.com/group/beast-users.
For more options, visit https://groups.google.com/d/optout.
--
==========================
Santiago Sanchez-Ramirez, PhD
Postdoctoral Associate
Ecology and Evolutionary Biology
University of Toronto
==========================
Reply all
Reply to author
Forward
0 new messages