| write_tree {castor} | R Documentation |
Write a phylogenetic tree to a file or a string, in Newick (parenthetic) format. If the tree is unrooted, it is first rooted internally at the first node.
write_tree(tree, file="", append=FALSE, digits=10)
tree |
A tree of class "phylo". |
file |
An optional path to a file, to which the tree should be written. The file may be overwritten without warning. If left empty (default), then a string is returned representing the tree. |
append |
Logical, specifying whether the tree should be appended at the end of the file, rather than replacing the entire file (if it exists). |
digits |
Number of significant digits for writing edge lengths. |
This function is comparable to (but typically much faster than) the ape function write.tree.
If file=="", then a string is returned containing the Newick representation of the tree. Otherwise, the tree is directly written to the file and no value is returned.
Stilianos Louca
# generate a random tree tree = generate_random_tree(list(birth_rate_intercept=1),max_tips=100)$tree # obtain a string representation of the tree in Newick format Newick_string = write_tree(tree)