# In this example the parrot clade is the genus of interest only the parrots
# are endemic to the island and all the passerines are not on the island
set.seed(1)
tree <- ape::rcoal(10)
tree$tip.label <- c(
"passerine_a", "passerine_b", "passerine_c", "passerine_d", "passerine_e",
"passerine_f", "parrot_a", "parrot_b", "parrot_c", "passerine_j")
tree <- phylobase::phylo4(tree)
endemicity_status <- c(
"not_present", "not_present", "not_present", "not_present", "not_present",
"not_present", "endemic", "endemic", "endemic", "not_present")
phylod <- phylobase::phylo4d(tree, as.data.frame(endemicity_status))
DAISIEprep::plot_phylod(phylod)
# the species 'parrot_a' is removed and becomes the missing species we want
# to the know the stem age for
phylod <- phylobase::subset(x = phylod, tips.exclude = "parrot_a")
DAISIEprep::plot_phylod(phylod)
extract_stem_age(
genus_name = "parrot",
phylod = phylod,
stem = "island_presence",
extraction_method = "min"
)
# here we use the extraction_method = "asr" which requires ancestral node
# states in the tree.
phylod <- add_asr_node_states(
phylod = phylod,
asr_method = "parsimony",
tie_preference = "mainland"
)
DAISIEprep::plot_phylod(phylod)
extract_stem_age(
genus_name = "parrot",
phylod = phylod,
stem = "island_presence",
extraction_method = "asr"
)
# lastly we extract the stem age based on the genus name
extract_stem_age(
genus_name = "parrot",
phylod = phylod,
stem = "genus",
extraction_method = NULL
)
Run the code above in your browser using DataLab