xavierdidelot / BactDating

Bayesian inference of ancestral dates on bacterial phylogenetic trees
https://xavierdidelot.github.io/BactDating
MIT License
80 stars 15 forks source link

Write result tree to nexus #22

Closed ConstantinV closed 4 years ago

ConstantinV commented 4 years ago

Hi! Thank you for BactDating. I wonder, how to write tree (after analysis) in nexus format with CI values for each node? I need to open this tree in Figtree for detailed analysis.

xavierdidelot commented 4 years ago

Hi Constantin, I had to make a small change to the BactDating code to get this to work, so please update to the latest version 1.0.7. You should then be able to use the following code to export to a nexus file for FigTree:

library(BactDating)
res=bactdate(...)
l=as.treedata.resBactDating(res)
library(treeio)
obj=methods::new('treedata',phylo=l[[1]],data=dplyr::tbl_df(as.data.frame(l[[2]])))
write.beast(obj,'test.nex')
ConstantinV commented 4 years ago

Thank you so much for the fast response!