Learn R Programming

rrnni (version 0.1.1)

sort_tips: Sort tip labels

Description

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

Usage

sort_tips(x)

# S3 method for phylo sort_tips(x)

# S3 method for multiPhylo sort_tips(x)

Value

an input tree with sorted tips

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.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab