sort_tips {rrnni}R Documentation

Sort tip labels

Description

Sort tip labels in a tree or a collection of trees.

Usage

sort_tips(x)

## S3 method for class 'phylo'
sort_tips(x)

## S3 method for class 'multiPhylo'
sort_tips(x)

Arguments

x

a tree of class "phylo" or a collection of trees of class "multiPhylo"

Details

The rnni function assumes tip labels in an unambiguous order. This is due to the internal implementation not having tip labels, tip/leave are instead identified by the index in the node matrix. The sort_tips orders the tip labels and change the node indices in the node matrix so that the tips for two different trees of the same taxa have the same node id.

Value

an input tree with sorted tips

Examples

# generate random trees
# use rcoal(5) instead of rankedPhylo(5)
# as ranked phylo always generate tip.labels
# in the same order.
t1 = ape::rcoal(5) |> rankedPhylo()
t2 = ape::rcoal(5) |> rankedPhylo()
t1s = sort_tips(t1)
t2s = sort_tips(t2)
all(tips(t1s) == tips(t2s))

# for collection of trees:
trees = c(t1, t2)
sort_tips(trees)


[Package rrnni version 0.1.1 Index]