knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(datelife)

The family Fringillidae is a taxon that includes the true finches. Let's see what is known about their time of divergence.

1. Getting species names within the family Fringillidae

DateLife searches its chronogram database using species names standardized to a unified taxonomy constructed by the Open Tree of Life project.

When working with taxon names above the species level in DateLife, the first step is to obtain all species names belonging to the taxon of interest.

We will get all species names belonging to the family Fringillidae, using the flag get_spp_from_taxon = TRUE from the function datelife::make_datelife_query():

dquery <- datelife::make_datelife_query(input = "fringillidae",               
                                   get_spp_from_taxon = TRUE)

Inspect the structure of the output:

str(dquery)
length(dquery$cleaned_names) == length(dquery$ott_ids)

We have r length(dquery$cleaned_names) species names belonging to the family Fringillidae according to OpenTree's unified taxonomy. We did not provide an input tree, so $phy is NA.

2. Search the species names across a chronogram database

Load the prebuilt OpenTree chronogram database object names opentree_chronograms:

utils::data("opentree_chronograms", package = "datelife")
opentree_chronograms$version

It is version r opentree_chronograms$version Use your datelifeQuery object named dquery to search the chronogram database:

dres <- datelife::get_datelife_result(input = dquery, cache = opentree_chronograms)

Results from the chronogram search are returned as a datelifeResult object, which is a named list of patristic matrices. Each element of the list corresponds to a chronogram that has been translated to a distance matrix or patristic matrix. The main reason for this is that pruning is much faster on a matrix than on a phylo object:

class(dres)
#> [1] "datelifeResult"

typeof(dres)
#> [1] "list"

class(dres[[1]])
#> [1] "matrix" "array"

Names on your datelifeResult object correspond to study citations from source chronograms:

names(dres)

3. Summarizing a datelifeResult object

What if you want to plot all your datelifeResult chronograms individually? What if you want a single tree summarizing all your source chronograms? The function datelife::summary.datelifeResult() will get all types of summaries for you, so you can access them later:

dsumm <- summary(dres, datelife_query = dquery)

Now we can explore different age summaries.

3.1 Source chronograms:

Chronograms that matched our database search, and that were pruned to contain only the species names we looked for are called source chronograms. These can be accessed as follow:

dsumm$phylo_all

#> 19 phylogenetic trees

By study name:

dsumm$phylo_all$`Gibb, Gillian C., Ryan England, Gerrit Hartig, P.A. (Trish) McLenachan, Briar L. Taylor Smith, Bennet J. McComish, Alan Cooper, David Penny. 2015. New Zealand passerines help clarify the diversification of major songbird lineages during the Oligocene. Genome Biology and Evolution 7 (11): 2983-2995.`

#> Phylogenetic tree with 7 tips and 6 internal nodes.
#> 
#> Tip labels:
#>   Schoeniclus_spodocephala, Emberiza_tristrami, Emberiza_chrysophrys, #> Emberiza_pusilla, Schoeniclus_aureolus, Serinus_canaria, ...
#> 
#> Rooted; includes branch lengths.

Or, by index position:

names(dsumm$phylo_all)[1]
dsumm$phylo_all[[1]]

To see how different datelife queries are made, check out the next tutorial vignette: Making a datelife query.

Mapping calibrations unto phylogenies

cc <- extract_calibrations_dateliferesult(input = dres)
class(cc)
head(cc)
spp = c("Caprimulgus aegyptius","Vanellus tricolor","Recurvirostra americana","Centropus nigrorufus","Bombycilla cedrorum","Orthotomus cinereiceps","Ortygospiza atricollis", "Nasica longirostris","Terpsiphone viridis", "Myiothlypis signata","Atlapetes melanopsis","Idiopsar brachyurus","Rauenia bonariensis","Lessonia oreas","Tyrannus niveigularis"  ,"Rukia longirostra","Zosterops ponapensis","Ixobrychus involucris","Melanerpes pulcher","Picus viridanus","Cynanthus canivetii")
bird_query = datelife::make_datelife_query(input = spp)

TODO add tests for the following functions: Dating with pathd8 is not working!

congruified_calibs <- congruify_and_mrca_multiPhylo(
                              phy =dsumm$phylo_median,
                              source_chronograms = dsumm$phylo_all)
uc <- use_calibrations(dating_method = "pathd8", 
                         phy = dsumm$phylo_median, 
                         calibrations = congruified_calibs)


phylotastic/datelife documentation built on June 9, 2024, 6:50 p.m.