SurvivingLineages: Finds unique surviving lineages of an extinction

Description Usage Arguments Details Value Author(s) Examples

View source: R/SurvivingLineages.R

Description

Finds unique surviving lineages of an extinction given a tree and vector of binary (extinction or survival) values.

Usage

1
SurvivingLineages(Tree, SurvivorVictim)

Arguments

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.

Details

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.

Value

A list of surviving lineages (may be clades - vectors of length greater than one) or individual tips (vectors of length one).

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

Examples

 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))))

graemetlloyd/metatree documentation built on April 29, 2021, 2:32 a.m.