Description Usage Arguments Details Value Author(s) Examples
View source: R/SurvivingLineages.R
Finds unique surviving lineages of an extinction given a tree and vector of binary (extinction or survival) values.
1 | SurvivingLineages(Tree, SurvivorVictim)
|
Tree |
A single tree in ape's phylo format. |
SurvivorVictim |
A numeric vector of victims (0) and survivors (1) with names matching to Tree$tip.label. |
Given a tree that crosses some extinction boundary, with both extinct and surviving species as tips, we might be interested in knowing how many individual lineages survived. This function finds unique lineages (sets of tips) that survive the boundary.
A list of surviving lineages (may be clades - vectors of length greater than one) or individual tips (vectors of length one).
Graeme T. Lloyd graemetlloyd@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Make sure random examples work:
set.seed(17)
# Generate a random 10 tip tree:
Tree <- ape::rtree(10)
# Remove branch lengths as they will not be used here:
Tree$edge.length <- NULL
# Create random vector of survivors (1) and victims (0):
SurvivorVictim <- sample(c(0, 1), size = 10, replace = TRUE)
# Assign tip names to survivors and victims:
names(SurvivorVictim) <- Tree$tip.label
# Run surviving lineages function on data:
SurvivingLineages(Tree, SurvivorVictim)
# Visually confirm results:
plot(Tree)
ape::tiplabels(SurvivorVictim)
# Generate multiple trees with same tip names:
Trees <- ape::rmtree(10, 10)
# Calculate just total number of survivors on each tree:
unlist(lapply(Trees, function(x) length(SurvivingLineages(x, SurvivorVictim = SurvivorVictim))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.