View source: R/find_unique_trees.r
find_unique_trees | R Documentation |
Given a set of trees with the same tip labels, returns just the unique topologies present.
find_unique_trees(trees)
trees |
An object of class |
Where labelled topologies are generated randomly or modified by (e.g.) removing a tip, it may be useful to isolate just those that are truly unique. The ape
package already has a function for this (unique.multiPhylo), but it can be slow when the number of trees is large. This function is thus intended as a faster version.
The function works by breaking down a tree into its' component bipartitions and treating the combination of these as the definition of the tree. It thus escapes problems due to the principle of free rotation. Specifically, these two trees are actually identical:
A B C D E \/ \ \/ \ \ / \ \/ \ / \ / \/ B A D E C \/ \/ / \ \ / \ \/ \ / \ / \/
This becomes clearer if we decompose them into their bipartitions:
AB, DE, CDE, ABCDE
These correspond to the descendants of each internal node (branching point) and the last one is actually ignored (the root node) as it will be present in any tree.
An object of class "multiPhylo"
.
Graeme T. Lloyd graemetlloyd@gmail.com
unique.multiPhylo
# Make a set of three identical trees (differing only in "rotation" of nodes):
trees <- ape::read.tree(text = c(
"((A,B),(C,(D,E)));",
"((C,(D,E)),(A,B));",
"((B,A),(C,(E,D)));")
)
# Show that there is only one unique tree:
find_unique_trees(trees = trees)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.