Learn R Programming

castor (version 1.3.6)

write_tree: Write a tree in Newick (parenthetic) format.

Description

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.

Usage

write_tree(tree, file="", append=FALSE, digits=10)

Arguments

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.

Value

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.

Details

This function is comparable to (but typically much faster than) the ape function write.tree.

See Also

read_tree

Examples

Run this code
# NOT RUN {
# 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)
# }

Run the code above in your browser using DataLab