combMyTree: Graft Polytomies on Tips of Phylogeny

View source: R/combMyTree.R

combMyTreeR Documentation

Graft Polytomies on Tips of Phylogeny

Description

Graft polytomies on the tips of a class phylo object.

Usage

combMyTree(phy, data, tips, brlen = 0, unit = "absolute", annotate = FALSE)

Arguments

phy

An object of class phylo.

data

A data frame with at least one column whose contents must be identical to the tip labels of the phylogeny in order to be matched automatically. Optionally, the new tip labels for the extended phylogeny can stem from another column, which is identified with tips.

tips

A character string giving the name of the column in data that contains the new tip labels. Alternatively, if tips is missing, combMyTree will create new tip labels by appending numbers to the former tip labels starting with 0.

brlen

A numeric giving either the absolute branch lengths or a fraction of some other value (depending on "unit").

unit

A character string according to which the number given by brlen will be interpreted. If it is "percent-root-age" (only possible with ultrametric trees), terminal branches will be assigned brlen times the root age and the whole tree will be rescaled so as not to change its age. All other strings will be interpreted as "absolute", i.e. terminal branches will be assigned brlen and the whole tree will not be rescaled.

annotate

Logical, if TRUE, the former tip labels will be turned into node labels. Note, that this will overwrite potentially existing node labels.

Value

An object of class phylo with nrow(data) tips.

See Also

forceEqualTipHeights

Examples

data(ips.tree)
## Simulate varying number of intraspecific observations
s <- sapply(1:Ntip(ips.tree), sample, x = 1:3, size = 1)
x <- rep(ips.tree$tip.label, times = s)
x <- data.frame(old_tips = x, 
                new_tips = paste0(x, unlist(lapply(s, function(z) 1:z))))
## Create polytomies, generate tip labels automatically
tre1 <- combMyTree(ips.tree, x, brlen = 0, unit = "absolute")
plot(tre1, no.margin = TRUE, cex =.5)
## Create polytomies, take tip labels from data frame
tre2 <- combMyTree(ips.tree, x, tips = "new_tips", brlen = 0, unit = "absolute")
plot(tre2, no.margin = TRUE, cex =.5)

ips documentation built on July 8, 2026, 5:07 p.m.