clone_tip: Clone tips

clone_tipR Documentation

Clone tips

Description

Clones tips as sisters of the original. Optionally, places the new clones and the original in their own subgroup, in which case the node for the new subgroup is assigned the same label as the original tip.

Usage

clone_tip(phy, label, n = 1, subgroup = FALSE)

Arguments

phy

A phylo object. The tree to manipulate.

label

A character vector containing tip labels.

n

A numeric vector. The number of clones to make.

subgroup

A logical. Whether to create a subgroup containing the new clones and their original.

Value

A phylo object containing the modified tree.

Examples


library(ape)

tree <- 
  rescale_branches_exp(abridge_labels(get_glottolog_trees("Tangkic")))
plot_glotto(tree)
tree2 <- clone_tip(tree, "nyan1300")
plot_glotto(tree2)

tree3 <- clone_tip(tree, "nyan1300", subgroup = TRUE)
plot_glotto(tree3)

# Add suffixes to labels, to keep all labels distinct
tree3a <- apply_duplicate_suffixes(tree3)
plot_glotto(tree3a)

tree4 <- clone_tip(tree, "lard1243", n = 3)
plot_glotto(tree4)

tree5 <- clone_tip(tree, "lard1243", n = 3, subgroup = TRUE)
plot_glotto(tree5)

tree6 <- clone_tip(tree, c("lard1243", "nyan1300"), n = 2, subgroup = TRUE)
plot_glotto(tree6)
tree6a <- apply_duplicate_suffixes(tree6)
plot_glotto(tree6a)

## Not run: 
# Returns error if any element of `label` is not in `phy`
tree7 <-  clone_tip(tree, c("lard1243", "xxxx1234"))

## End(Not run)

erichround/glottoTrees documentation built on April 17, 2025, 10:47 a.m.