validate_tree {MethEvolSIM} | R Documentation |
Validate and Parse a Phylogenetic Tree
Description
This function checks whether the input is a valid phylogenetic tree, either as a character string in Newick format
or as an object of class phylo
from the ape
package. If the input is a Newick string, it is parsed into
a phylo
object. The function also ensures that the tree contains at least two tips.
Usage
validate_tree(tree)
Arguments
tree |
A phylogenetic tree in Newick format (as a character string) or an object of class
|
Details
The function first verifies that the input is either a valid
phylo
object or a character string.If the input is a Newick string, it attempts to parse it into a
phylo
object usingape::read.tree()
.If parsing fails, an informative error message is returned.
The function also checks that the tree contains at least two tips, as a valid phylogenetic tree should have at least one split.
Value
A phylo
object representing the validated and parsed tree.