Skip to contents

Convert a tree of class "phylo" to a ranked tree of class "rankedPhylo".

Usage

as_ranked(x)

Arguments

x

a tree of class "phylo"

Value

a ranked tree of class "rankedPhylo"

Details

To convert a tree to a ranked tree, the tree needs to be binary (i.e., fully resolved), be rooted, and ultrametric. Typically, such tree would be produced by coalescent process.

Ranked trees are similar to time-trees, only instead of time, we care about the order of the splits.

Examples


# this will throw an error, the tree is not ultrametric
x = ape::rtree(5)
try(as_ranked(x))
#> Error in as_ranked(x) : Input tree must be ultrametric.

# coalescent trees can be converted without problem
y = ape::rcoal(5)
as_ranked(y)
#> 
#> Phylogenetic tree with 5 tips and 4 internal nodes.
#> 
#> Tip labels:
#>   t4, t5, t1, t3, t2
#> 
#> Rooted; includes branch lengths.