read_binary_trees.Rd
This function reads a file containing one or more trees in binary format.
read_binary_trees(file, tree.names = NULL, keep.multi = FALSE)
file | A file name. |
---|---|
tree.names | A vector of mode character containing names for the trees that are read from the file;
if |
keep.multi | If |
An object of class "phylo"
or "multiPhylo"
, compatible with the ape
package.
In addition to the elements described in the documentation for the read.tree
function of the ape
package, a "phylo"
object produced by this function
will also have the following components:
tip.attributes
A named list of attributes for the tips of the tree. Each element of this list is a vector of mode character or numeric (depending on the attribute).
node.attributes
A named list of attributes for the internal nodes of the tree. Each element of this list is a vector of mode character or numeric (depending on the attribute).
This function reads the whole file in memory at once. If you wish to process the file tree-by-tree, you
should use the read_one_binary_tree
function.
Node attributes (e.g. support values, rates, ages...) are parsed by this function and returned in the
tip.attributes
and node.attributes
elements of the returned "phylo"
objects.
Attribute names may appear in any kind of casing (e.g. Name
, name
or NAME
), but they
should be treated using case-insensitive comparisons.
If the file has an invalid trailer (e.g. because it is incomplete), the function will print a warning and attempt anyways to extract as many trees as possible.
https://github.com/arklumpus/TreeNode/blob/master/BinaryTree.md
read_one_binary_tree
, ape
, read.tree
Other functions to read trees:
read_nwka_nexus()
,
read_nwka_tree()
,
read_one_binary_tree()
# Tree file (replace with your own) treeFile <- system.file("extdata", "oneTree.tbi", package="TreeNode") # Read the tree file tree <- read_binary_trees(treeFile) # Use support values as node labels tree$node.label = tree$node.attributes$Support # Plot the tree with support values at the nodes ape::plot.phylo(tree, show.node.label = TRUE)