node_clades.RdThis function is used to determine the descendant species of each node in a phylogenetic tree. This function requires the package 'ape' and 'phangorn'
node_clades(
tree,
data,
tip.lvl,
species,
sep = "_",
report = TRUE,
age = FALSE
)A time-resolved newick formatted tree
A data frame of occurrence or taxonomic data
A character equal to the name of the column in data that holds the tip labels of tree.
A character equal to the name of the column in data that holds the species' names.
A character equal to the separator of the tip labels and the separator to be used in the column headers
of the resultant data frame.
For example: for 'Apis_mellifera' sep = '_' (the default) or for 'Apis.mellifera' sep = '.'
Logical. If TRUE, the species or groups (i.e. tip labels) that are in data but not in tree
are returned.
Logical. If TRUE, the clade crown ages are calculated and returned in the matrix.
A i x j data frame of presence/absence of j species in i clades determined by the phylogenetic nodes.
tree <- read.tree(file.path(here(), 'data_raw', 'trees', 'Tetrapoda_genus.nwk'))
#> Error in read.tree(file.path(here(), "data_raw", "trees", "Tetrapoda_genus.nwk")): could not find function "read.tree"
herp <- read.csv(file.path(here(), 'data_raw', 'IBT_Herp_Records_final.csv'), header = TRUE)
#> Error in here(): could not find function "here"
taxa <- read.csv(file.path(here(), 'data_raw', 'IBT_Sp_Taxonomy_v1.csv'), header = TRUE)
#> Error in here(): could not find function "here"
names(taxa)[which(names(taxa) == 'sp_in_Data')] <- 'binomial'
#> Error in names(taxa)[which(names(taxa) == "sp_in_Data")] <- "binomial": object 'taxa' not found
herp <- merge(herp, taxa[, c('binomial', 'Genus')], by = 'binomial', all = TRUE)
#> Error in merge(herp, taxa[, c("binomial", "Genus")], by = "binomial", all = TRUE): object 'herp' not found
clades <- node_clades(tree = tree, data = herp, tip.lvl = 'Genus', species = 'binomial', sep = '_', report = TRUE)
#> Error in is.factor(x): object 'herp' not found