apply_duplicate_suffixes | R Documentation |
Suffixes are applied to ensure tip labels and node labels are not duplicates. Suffixes have the form -1, -2, -3, ...
apply_duplicate_suffixes(phy)
phy |
A phylo object, the tree whose labels are to have copy suffixes applied. |
The function recognizes existing duplicate suffixes and deals with them in one of two ways. If a label has n duplicates that are already suffixed -1, -2, ... -n, then the suffixes are not changed. Under any other conditions, old suffixes are removed and new ones applied.
Suffixation of tips and of nodes are handled independently of one another.
A phylo object, the same tree but with suffixes applied to the labels.
library(ape)
tree <- abridge_labels(get_glottolog_trees("Koreanic"))
plot_glotto(tree)
tree2 <- clone_tip(tree, "chol1278", n = 2, subgroup = TRUE)
plot_glotto(tree2)
# Technically, tree2 is ill-formed because it has duplicate tip labels.
# Note how this causes problems if we try to clone one of them, since it
# is unclear which should be cloned:
## Not run:
tree2a <- clone_tip(tree2, "chol1278")
## End(Not run)
# Suffixation of duplicate tips
tree3 <- apply_duplicate_suffixes(tree2)
plot_glotto(tree3)
# Once they are suffixed, these tips can be cloned successfully:
tree4 <- clone_tip(tree3, c("chol1278-2", "chol1278-3"), subgroup = TRUE)
plot_glotto(tree4)
# Suffixing is applied across all tips that share a glottocode, and
# separately, across all nodes that share a glottocode:
tree5 <- apply_duplicate_suffixes(tree4)
plot_glotto(tree5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.