Learn R Programming

megaptera (version 1.0-0)

addTip: Add Tips to a Phylogeny

Description

This function adds tips (terminal nodes) to a (currently ultrametric) phylogenetic tree.

Usage

addTip(phy, tip, tax, insert = "crown", stem.edge = 0.5)

Arguments

phy
an object of class phylo; must be ultrametric.
tip
a character string giving the name of the species to be added.
tax
a data frame containing a taxonomy.
insert
a character string indicating the positions where the species is to be inserted: "crown", "stem", "randomly", or any unambigous abbreviation of these. This option will only have an effect if phy contains more than one congeneric of tip.
stem.edge
a real number greater than 0 and smaller than 1, which gives the fraction of the terminal branch length that will be assigned to the branch subtending the newly created MRCA of tip and its single congeneric species in phy. Will have no effect if phy contains more than one congeneric of tip.

Value

an object of class phylo containing at least one multichotomous node.

Details

tip will be added at the crown group level of the genus. This means there must be a monophyletic generic clade in the phylogeny that matches the genus name of tip

See Also

prune.phylo.rank for pruning phylogenies to a particular taxonomic level.

Examples

Run this code
## random ultrametric tree
## -----------------------
#set.seed(12)
#phy <- rcoal(20, tip.label = paste("whale", LETTERS[1:20]))
#phy$tip.label[6:9] <- gsub("whale", "humpback", phy$tip.label[6:9])
#phy$tip.label[12] <- gsub("whale", "humpback", phy$tip.label[12])
#phy <- fixNodes(ladderize(phy))
#plot(phy, no.margin = TRUE); nodelabels(cex = .5)

## default use adding four species
## -------------------------------
#spec <- c("Athelia V",
#          paste("Cladonia", c("X", "Y", "Z")))
#phy.crown <- phy
#for (i in seq_along(spec)) 
 # phy.crown <- addTip(phy.crown, spec[i])
#plot(phy.crown, no.margin = TRUE); nodelabels(cex = .5)

## random addition of tips to their genus
## ---------------------------------------
#spec <- paste("Cladonia", c("X", "Y", "Z"))
#phy.random <- phy
#for (i in seq_along(spec)) 
#  phy.random <- addTip(phy.random, spec[i], insert = "randomly")
#plot(phy.random, no.margin = TRUE); nodelabels(cex = .5)

Run the code above in your browser using DataLab