Create a new, or coerce character vector or an existing tree into a ranked tree.
Usage
rankedPhylo(x)
# S3 method for default
rankedPhylo(x)
# S3 method for numeric
rankedPhylo(x)
# S3 method for character
rankedPhylo(x)
# S3 method for phylo
rankedPhylo(x)
# S3 method for multiPhylo
rankedPhylo(x)
Arguments
- x
a numeric vector, character vector or a object of class
phylo
ormultiPhylo
, see details.
Details
This is a wrapper for multiple functions that create a ranked tree.
As such, it accepts multiple types of inputs and produce either rankedPhylo
or
a collated list of ranked trees as a multiRankedPhylo
.
If x
is a numeric vector, create n = length(x)
random ranked tree using the random_tree
function.
If x
is a character vector, try to read the character as a newick-formatted tree.
If x
is object of a class phylo
or multiPhylo
, coerce these objects into rankedPhylo
or multiRankedPhylo
using the as_ranked
function.
Examples
# Create a single random ranked tree with 5 tips
rankedPhylo(5)
#>
#> Phylogenetic tree with 5 tips and 4 internal nodes.
#>
#> Tip labels:
#> t1, t2, t3, t4, t5
#>
#> Rooted; includes branch lengths.
# Create multiple random ranked trees with 5 tips
rankedPhylo(c(5,5,5))
#> 3 phylogenetic trees
# Convert a coalescent tree into a ranked tree
x = ape::rcoal(5) # random coalescent tree
rankedPhylo(x)
#>
#> Phylogenetic tree with 5 tips and 4 internal nodes.
#>
#> Tip labels:
#> t4, t1, t2, t3, t5
#>
#> Rooted; includes branch lengths.