Export treedata object to BEAST NEXUS file. This function was adopted and modified from ape::write.nexus

write.beast(treedata, file = "", translate = TRUE, tree.name = "UNTITLED")

Arguments

treedata

treedata object

file

output file. If file = "", print the output content on screen

translate

whether translate taxa labels

tree.name

name of the tree

Value

output file or file content on screen

Author

Guangchuang Yu

Examples

nhxfile <- system.file("extdata/NHX", "phyldog.nhx", package="treeio")
nhx <- read.nhx(nhxfile)
write.beast(nhx)
#> #NEXUS
#> [R-package treeio, Fri Nov 12 07:12:23 2021]
#> 
#> BEGIN TAXA;
#> 	DIMENSIONS NTAX = 16;
#> 	TAXLABELS
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 		[email protected]
#> 	;
#> END;
#> BEGIN TREES;
#> 	TRANSLATE
#> 		1	[email protected],
#> 		2	[email protected],
#> 		3	[email protected],
#> 		4	[email protected],
#> 		5	[email protected],
#> 		6	[email protected],
#> 		7	[email protected],
#> 		8	[email protected],
#> 		9	[email protected],
#> 		10	[email protected],
#> 		11	[email protected],
#> 		12	[email protected],
#> 		13	[email protected],
#> 		14	[email protected],
#> 		15	[email protected],
#> 		16	[email protected]
#> 	;
#> 	TREE * UNTITLED = [&R] (((1[&Ev=S,ND=0,S=58]:0.0682841,(2[&Ev=S,ND=1,S=69]:0.0193941,3[&Ev=S,ND=2,S=70]:0.0121378)[&Ev=S,ND=3,S=60]:0.0217782)[&Ev=S,ND=4,S=36]:0.0607598,((4[&Ev=S,ND=9,S=31]:0.11832,(((5[&Ev=S,ND=10,S=37]:0.0144549,6[&Ev=S,ND=11,S=38]:0.0149723)[&Ev=S,ND=12,S=33]:0.0925388,7[&Ev=S,ND=13,S=61]:0.077429)[&Ev=S,ND=14,S=24]:0.0274637,(8[&Ev=S,ND=15,S=52]:0.0761163,((9[&Ev=S,ND=16,S=53]:0.0906068,10[&Ev=S,ND=17,S=54]:1e-06)[&Ev=S,ND=18,S=45]:1e-06,((11[&Ev=S,ND=19,S=65]:0.120851,12[&Ev=S,ND=20,S=71]:0.133939)[&Ev=S,ND=21,S=56]:1e-06,13[&Ev=S,ND=22,S=64]:0.0693814)[&Ev=S,ND=23,S=46]:1e-06)[&Ev=S,ND=24,S=40]:0.0333823)[&Ev=S,ND=25,S=35]:1e-06)[&Ev=D,ND=26,S=24]:0.0431861)[&Ev=S,ND=27,S=19]:1e-06,14[&Ev=S,ND=28,S=26]:0.22283)[&Ev=S,ND=29,S=17]:0.0292362)[&Ev=D,ND=8,S=17]:0.185603,(15[&Ev=S,ND=5,S=16]:0.0621782,16[&Ev=S,ND=6,S=15]:0.332505)[&Ev=S,ND=7,S=12]:0.185603)[&Ev=S,ND=30,S=9];
#> END;