ape (version 1.4)

drop.tip: Remove Tips in a Phylogenetic Tree

Description

This function removes the terminal branches of a phylogenetic tree, possibly removing the corresponding internal branches.

Usage

drop.tip(phy, tip, trim.internal = TRUE, subtree = FALSE)

Arguments

phy
an object of class "phylo".
tip
a vector of mode numeric or character specifying the tips to delete.
trim.internal
a logical specifying whether to delete the corresponding internal branches.
subtree
a logical specifying whether to output in the tree how many tips have been deleted and where.

Value

  • an object of class "phylo".

Details

The argument tip can be either character or numeric. In the first case, it gives the labels of the tips to be deleted; in the second case the numbers of these labels in the vector phy$tip.label are given. If trim.internal = FALSE, the new tips are given "NA" as labels, unless there are node labels in the tree in which case they are used. If subtree = TRUE, the returned tree has one or several terminal branches indicating how many tips have been removed (with a label "[x_tips]"). This is done for as many monophyletic groups that have been deleted. Note that subtree = TRUE implies trim.internal = TRUE.

See Also

bind.tree, root, rotate

Examples

Run this code
data(bird.families)
tip <- c(
"Eopsaltriidae", "Acanthisittidae", "Pittidae", "Eurylaimidae",
"Philepittidae", "Tyrannidae", "Thamnophilidae", "Furnariidae",
"Formicariidae", "Conopophagidae", "Rhinocryptidae", "Climacteridae",
"Menuridae", "Ptilonorhynchidae", "Maluridae", "Meliphagidae",
"Pardalotidae", "Petroicidae", "Irenidae", "Orthonychidae",
"Pomatostomidae", "Laniidae", "Vireonidae", "Corvidae",
"Callaeatidae", "Picathartidae", "Bombycillidae", "Cinclidae",
"Muscicapidae", "Sturnidae", "Sittidae", "Certhiidae",
"Paridae", "Aegithalidae", "Hirundinidae", "Regulidae",
"Pycnonotidae", "Hypocoliidae", "Cisticolidae", "Zosteropidae",
"Sylviidae", "Alaudidae", "Nectariniidae", "Melanocharitidae",
"Paramythiidae","Passeridae", "Fringillidae")
plot(drop.tip(bird.families, tip))
plot(drop.tip(bird.families, tip, trim.internal = FALSE))
data(bird.orders)
plot(drop.tip(bird.orders, 6:23, subtree = TRUE), font = 1)
plot(drop.tip(bird.orders, c(1:5, 20:23), subtree = TRUE), font = 1)

Run the code above in your browser using DataLab