sort_tips | R Documentation |
Sort tip labels in a tree or a collection of trees.
sort_tips(x)
## S3 method for class 'phylo'
sort_tips(x)
## S3 method for class 'multiPhylo'
sort_tips(x)
x |
a tree of class "phylo" or a collection of trees of class "multiPhylo" |
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.
an input tree with sorted tips
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.