How to work on MCC trees annotations

519 views
Skip to first unread message

Mj

unread,
Jul 22, 2015, 11:36:16 AM7/22/15
to beast-users
Dear Marc and dear all,

I have performed BEAST v1.8.2 phylogeographic analysis (RWW continuous diffusion models) and extracted maximum clade credibility trees using Tree Annotator.

I wanted to work on annotations of trees thanks to the read.annotated.nexus function of the OutbreakTools package. However, when I plot the tree in R in it is not the same I obtained using FigTree v1.4.2. The topology looks similar but taxa are not distributed on the same way.

I can’t understand why. Here is the simple R code I am using:
library(OutbreakTools)
tree <- read.annotated.nexus(“MCC_Tree.tree")
plot(tree, cex=0.2, font=1, family=“Arial")

Could you please help me? Can I work on annotations in R even if it seems to have a problem? .. or is there another way to work properly on branchs' and nodes' annotations (diffusion rates, latitudes and longitudes of internal nodes...)?

Any thoughts would be appreciated.

Here attached the trees I obtained with both softwares and the nexus file.

Many thanks,

Maude

FigTree.pdf
MCC_Tree.tree
Rplot.pdf

Marc Suchard

unread,
Jul 23, 2015, 11:41:49 AM7/23/15
to beast-users, maude....@gmail.com
Hi Maude,

I recently (May 2015) made some significant fixes to read.annotated.nexus() and am not sure if Thibaut has updated the OutbreakTools version on CRAN.  So, please try to install the development version (instructions below) and see if that fixes your issue.  If you are still having trouble with the development version, please let me know and I try to schedule some time to take a closer look at your *.tree file.

To install the development version of OutbreakTools
  
  install.packages("devtools")
  devtools::install_github("thibautjombart/OutbreakTools")

Finally, Thibaut continues to put a large amount of effort into OutbreakTools, so please remember to cite: Jombart et al. (2014) Epidemics, 7, 28 - 34.

best, Marc

Mj

unread,
Jul 23, 2015, 11:51:38 AM7/23/15
to beast-users, msuc...@gmail.com
Hi Marc,

I looks much better. Thank you very much.

Of course, I'll let you know if I can see anything else.

Best wishes,

Maude

Maude Jacquot

unread,
Aug 6, 2015, 5:54:31 AM8/6/15
to beast-users, msuc...@gmail.com
Hi again Marc,

Is there any way to read multiple annotated trees on the same time? I mean, if I want to work on the .trees files generated by BEAST (phylogeography) and which contain all the sampled annotated-trees along the MCMC.
All I tried did not work.

Thanks,

Maude

Marc A. Suchard

unread,
Aug 9, 2015, 9:31:54 AM8/9/15
to Maude Jacquot, beast-users

Hi Maude,

It looks like I need to update the multi-tree reading capability in OutbreakTools. Can you email me an example *.tre file with multiple trees that you’d like to be able to load?

best, Marc

Maude Jacquot

unread,
Aug 10, 2015, 3:37:58 AM8/10/15
to Marc A. Suchard, beast...@googlegroups.com
Hi Marc,

Thank you for your reply. Here, is the example on which I am working to perform tests (113 Taxa, 4 annotated trees).

Many thanks for your help,

Maude
--

Maude JACQUOT
Institute of Biodiversity, Animal Health and Comparative Medicine
College of Medical, Veterinary & Life Sciences
Room 306, Graham Kerr Building
University of Glasgow, Glasgow, G12 8QQ
Tél: +44 (0)141 330 6626

MultiAnnotated_test.trees

Marc Suchard

unread,
Aug 10, 2015, 6:54:52 AM8/10/15
to beast-users
I committed a bug-patch to OutbreakTools this morning and think I am able to correct read those 4 trees.  Try:

    devtools::install_github("thibautjombart/OutbreakTools")
    trees <- read.annotated.nexus("MultiAnnotated_test.trees")

best, Marc

Maude Jacquot

unread,
Aug 10, 2015, 11:32:39 AM8/10/15
to beast-users
Hi Marc,

I re-installed and loaded the development version of OutbreakTools.
>  devtools::install_github("thibautjombart/OutbreakTools")
> library(OutbreakTools)

Now, I can read the 4 trees,
> Trees <- read.annotated.nexus("MultiAnnotated_test.trees")
> Trees
4 phylogenetic trees

But I still have problem to access to the annotations. I only get tip labels:
> names(Trees[1]$annotations)
[1] "tip.label"
> names(Trees[1]$annotations[[1]])
NULL

For each tree, I would like to get the whole annotations such as:
> Tree <- read.annotated.nexus("SingleTree_test.tree")>
> names(Tree$annotations[[1]])
 [1] "location.rate"            "length_range"               
 [3] "location2_median"         "height_range"               
 [5] "location1_range"          "rate_95%_HPD"               
 [7] "location.rate_range"      "rate_range"                 
 [9] "location2_80%HPD_1"       "location1_80%HPD_1"     
[11] "rate"                         "height"                     
[13] "rate_median"                  "length"                     
[15] "location1_median"         "height_95%_HPD"             
[17] "length_95%_HPD"               "location.rate_median"   
[19] "height_median"                "location2_range"        
[21] "posterior"                    "location_80%HPD_modality"
[23] "location2"                "location1"              
[25] "length_median"                "location.rate_95%_HPD"  

Maybe I'm doing something wrong. Sorry about that and many thanks for your prompt answers, I really appreciate it!

Best wishes,

Maude

Bram

unread,
Aug 11, 2015, 10:52:11 AM8/11/15
to beast-users
Hi Maude,

To acces an annotation 'X', you can follow the instructions (on p41) of the outbreaktools manual:
annotX <- unlist(sapply(tree$annotations, function(e) e$X))
or access them directly
tree$annotations[[traitIndex]][traitName][[1]][1]

Good luck,
Bram


Op maandag 10 augustus 2015 17:32:39 UTC+2 schreef Maude Jacquot:

Marc Suchard

unread,
Aug 11, 2015, 11:37:40 AM8/11/15
to beast-users
Hi Maude,

Am not sure what to suggest here.   I get the following in a fresh R environment:

> devtools::install_github("thibautjombart/OutbreakTools")
Downloading github repo thibautjombart/OutbreakTools@master
Installing OutbreakTools
'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD INSTALL  \
  '/private/var/folders/hj/cd3d04l17yx9698r3mw0zhzm0000gn/T/Rtmpq8aMQ2/devtools131961073a4d/thibautjombart-OutbreakTools-5bf5380'  \
  --library='/Library/Frameworks/R.framework/Versions/3.1/Resources/library' --install-tests 

* installing *source* package ‘OutbreakTools’ ...
** R
** data
** inst
** preparing package for lazy loading
Creating a generic function for ‘plot’ from package ‘graphics’ in package ‘OutbreakTools’
Creating a generic function for ‘as.matrix’ from package ‘base’ in package ‘OutbreakTools’
Creating a generic function for ‘as.data.frame’ from package ‘base’ in package ‘OutbreakTools’
Creating a generic function for ‘summary’ from package ‘base’ in package ‘OutbreakTools’
Creating a generic function for ‘head’ from package ‘utils’ in package ‘OutbreakTools’
Creating a generic function for ‘tail’ from package ‘utils’ in package ‘OutbreakTools’
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (OutbreakTools)
> library(OutbreakTools)
Loading required package: ggplot2
Loading required package: network
network: Classes for Relational Data
Version 1.10.2 created on 2014-06-12.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
                    Mark S. Handcock, University of California -- Los Angeles
                    David R. Hunter, Penn State University
                    Martina Morris, University of Washington
                    Skye Bender-deMoll, University of Washington
 For citation information, type citation("network").
 Type help("network-package") to get started.

Loading required package: knitr
 OutbreakTools 0.1-13.999 has been loaded

> Trees <- read.annotated.nexus("MultiAnnotated_test.trees")
> names(Trees[[1]]$annotations[[1]])
[1] "locationSeg1.rate" "locationSeg1"      "rate" 

and these appear to be the only traits that I see MultiAnnotated_test.trees.  

best, M

Santiago Sánchez

unread,
Aug 11, 2015, 11:50:13 AM8/11/15
to beast...@googlegroups.com
From what I see, I think Maude missed two square brackets (highlighted in red) in her example:

> names(Trees[[1]]$annotations[[1]])

Cheers,
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

Maude Jacquot

unread,
Aug 12, 2015, 3:51:58 AM8/12/15
to beast-users
Dear all,

Santiago has seen right: missing brackets, sorry. Now, I am glad to be able to work on multi-annotated tree!
Your help was definitively very useful. Many thanks.

All the best,

Maude
Reply all
Reply to author
Forward
0 new messages