clade_age.Rd
This function is used to calculate the crown ages for a set of clades within a phylogenetic tree. This function requires the package 'ape'
clade_age(tree, taxonomy, species, clades, total = TRUE, sp_sep = " ")
A time-resolved newick formatted tree with tip labels equal to the species binomial names with an "_" such as the trees downloaded from timetree.org.
A data frame with each row holding the species' taxonomic hierarchy, such as what
is returned from hierarchy()
, or the clade names in which each species belongs.
A character equal to the name of the column that holds the species binomial names. This column can also to be a different taxonomic level if needed.
A character or vector equal to the name(s) of the columns that holds the clade names
Logical. If TRUE
, the crown age for the entire group of species is returned
A character equal to the separator of the binomial name in the species name column.
For example: for 'Apis mellifera' sp_sep = ' '
or for 'Apis.mellifera' sp_sep = '.'
A data frame with three columns. One for the clade name, one for the clade rank (i.e. column name in the input data frame), and one for the crown age of the clade.
if (FALSE) {
library(here)
library(ape)
tree <- read.tree(file.path(here(), 'data_raw', 'Tetrapoda_species.nwk'))
herp <- read.csv(file.path(here(), 'data_out', 'supp_info', 'IBT_Carib_Taxonomy.csv'), header=TRUE)
ages <- clade_age(tree = tree,
taxonomy = taxa,
species = 'sp_in_Data',
clades = c("Class", "Order", "Family", "Genus"),
total = TRUE,
sp_sep = " ")
}