abridge_labels: Shorten labels to a glottocode substring

View source: R/labels.R

abridge_labelsR Documentation

Shorten labels to a glottocode substring

Description

Shortens tip and node labels to a glottocode substring within them. If any labels lack a glottocode substring, a warning is given.

Usage

abridge_labels(phy)

Arguments

phy

A phylo or multiPhylo object, containing one or more trees to manipulate.

Details

Glottocodes comprise four lowercase letters (or b10b or 3adt) followed by four numbers, and are only identified if they are initial in the string or are preceded by <.

Also recognizes and retains duplicate suffixes, i.e., a hyphen followed by one or more numerals at the end of the string (see apply_duplicate_suffixes).

Value

A phylo or multiPhylo object, the manipulated tree(s).

Examples


library(ape)

tree <- get_glottolog_trees("Koreanic")
plot(tree)
nodelabels(tree$node.label)
tree2 <- abridge_labels(tree)
plot(tree2)
nodelabels(tree2$node.label)

# Retain duplicate suffixes:
tree3 <- clone_tip(tree, "Jollado<chol1278>", n = 2, subgroup = TRUE)
tree3a <- apply_duplicate_suffixes(tree3)
plot(tree3a)
nodelabels(tree3a$node.label)
tree4 <- abridge_labels(tree3a)
plot(tree4)
nodelabels(tree4$node.label)

# A warning is issued if any label does not contain a glottocode
supertree <- assemble_supertree() # contains nodes without glottocodes
supertree2 <- abridge_labels(assemble_supertree())

# Applied to a `multiPhylo` object:
trees <- get_glottolog_trees(c("Kartvelian", "Basque"))
trees2 <- abridge_labels(trees)
plot(trees[[1]])
nodelabels(trees[[1]]$node.label)
plot(trees2[[1]])
nodelabels(trees2[[1]]$node.label)
plot(trees[[2]])
nodelabels(trees[[2]]$node.label)
plot(trees2[[2]])
nodelabels(trees2[[2]]$node.label) 

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