aptg builds phylogenetic trees and distance matrices
from a list of taxon names, or from a higher taxon expanded down to a
lower rank.
Version 0.2.x is a rewrite: the original
Phylomatic/brranching backend was archived from CRAN and
its web service shut down, so trees now come from the Open Tree
of Life synthetic tree (via rotl) or, for
ray-finned fishes, the dated Fish Tree of Life (via fishtree). See
NEWS.md and MIGRATION.md for details.
# install.packages("remotes")
remotes::install_github("christophebenjamin/aptg")
# For the dated fish backend (optional):
install.packages("fishtree")library(aptg)
# A mixed list is split by phylum: no tree ever spans above phylum.
res <- taxa.tree(c("Canis lupus", "Alces alces", "Rangifer tarandus",
"Acer saccharum", "Acer rubrum", "Betula alleghaniensis"))
names(res$trees) # "Chordata" "Streptophyta"
plot(res$trees[["Chordata"]]$tree)
res$trees[["Chordata"]]$dist # distance matrix
# Expand a higher taxon down to a rank, then build the tree(s).
downto.tree("Cervidae", downto = "species")
# A dated fish chronogram (needs the fishtree package).
taxa.tree(c("Thunnus thynnus", "Gadus morhua", "Salmo salar", "Danio rerio"),
source = "fish")
# Trees for a clade within a geographic area (needs rgbif; radius needs
# geosphere). Species come from GBIF occurrence records.
region.tree("Aves", lat = 45.50, lon = -73.57, radius_km = 50) # radius
region.tree("Mammalia", province = "Nunavut") # Canadian territory
region.tree("Reptilia", gadm = "USA.5_1") # any GADM arearegion.tree() supports all 13 Canadian provinces and
territories by name or postal code (AB, BC, MB, NB, NL, NT, NS, NU, ON,
PE, QC, SK, YT). Note that GBIF returns occurrence records, not a
curated checklist, so the species list is sampling-biased — see
?region.tree.
downto.tree() uses NCBI via taxize. To
raise the rate limit (3 to 10 req/s), pass an Entrez key as
key = "..." (it is exported as ENTREZ_KEY for
the call) or set ENTREZ_KEY in your .Renviron
and leave key = NULL.
Both functions return, invisibly,
list(trees, unmatched), where trees is named
by phylum and each element is list(tree, dist). The Open
Tree backend is topology-only (distances are edge counts); the fish
backend returns a dated chronogram (patristic/time distances).
MIT (c) Christophe Benjamin. See LICENSE.