Title: | Fetch 'Phylogenies' from Many Sources |
---|---|
Description: | Includes methods for fetching 'phylogenies' from a variety of sources, including the 'Phylomatic' web service (<http://phylodiversity.net/phylomatic/>), and 'Phylocom' (<https://github.com/phylocom/phylocom/>). |
Authors: | Scott Chamberlain [aut] , Luna L Sanchez Reyes [ctb, cre] |
Maintainer: | Luna L Sanchez Reyes <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.7.1 |
Built: | 2024-11-27 03:54:54 UTC |
Source: | https://github.com/ropensci/brranching |
Query Phylomatic for a phylogenetic tree.
phylomatic( taxa, taxnames = TRUE, get = "GET", informat = "newick", method = "phylomatic", storedtree = "R20120829", treeuri = NULL, taxaformat = "slashpath", outformat = "newick", clean = TRUE, db = "apg", mssgs = TRUE, ... )
phylomatic( taxa, taxnames = TRUE, get = "GET", informat = "newick", method = "phylomatic", storedtree = "R20120829", treeuri = NULL, taxaformat = "slashpath", outformat = "newick", clean = TRUE, db = "apg", mssgs = TRUE, ... )
taxa |
Phylomatic format input of taxa names. |
taxnames |
If |
get |
'GET' (default) or 'POST' format for submission to the website. |
informat |
One of newick (default), nexml, or cdaordf. If using a stored tree, informat should always be newick. |
method |
One of phylomatic (default) or convert |
storedtree |
One of R20120829 (Phylomatic tree R20120829 for plants), smith2011 (Smith 2011, plants), binindaemonds2007 (Bininda-Emonds 2007, mammals), or zanne2014 (Zanne et al. 2014, plants). Default: R20120829 |
treeuri |
URL for a phylogenetic tree in newick format. |
taxaformat |
Only option is slashpath for now. Leave as is. |
outformat |
One of newick, nexml, or fyt. |
clean |
Return a clean tree or not. Default: |
db |
One of "ncbi", "itis", or "apg". Default: apg |
mssgs |
Print messages. Default: |
... |
curl options passed on to crul::HttpClient |
Use the web interface at http://phylodiversity.net/phylomatic/
If you set taxnames = FALSE
, you need to pass in a character
vector, with each element like this example:
"asteraceae/taraxacum/taraxacum_officinale"
, of the form
"family/genus/genus_specfic epithet"
Newick formatted tree as phylo
object or
nexml character string
## Not run: # Input taxonomic names taxa <- c("Poa annua", "Phlox diffusa", "Helianthus annuus") tree <- phylomatic(taxa=taxa, get = 'POST') plot(tree, no.margin=TRUE) # Genus names taxa <- c("Poa", "Phlox", "Helianthus") tree <- phylomatic(taxa=taxa, storedtree='R20120829', get='POST') plot(tree, no.margin=TRUE) # Lots of names taxa <- c("Poa annua", "Collomia grandiflora", "Lilium lankongense", "Phlox diffusa", "Iteadaphne caudata", "Gagea sarmentosa", "Helianthus annuus") tree <- phylomatic(taxa=taxa, get = 'POST') plot(tree, no.margin=TRUE) # Don't clean - clean=TRUE is default (tree <- phylomatic(taxa=taxa, clean = FALSE)) ## with clean=FALSE, you can get non-splitting nodes, which you ## need to collpase before plotting library('ape') plot(collapse.singles(tree), no.margin=TRUE) # Output NeXML format taxa <- c("Gonocarpus leptothecus", "Gonocarpus leptothecus", "Lilium lankongense") out <- phylomatic(taxa=taxa, get = 'POST', outformat = "nexml") cat(out) # Lots of names, note that when you have enough names (number depends on length of individual # names, so there's no per se rule), you will get an error when using `get='GET'`, # when that happens use `get='POST'` library("taxize") spp <- names_list("species", 500) # phylomatic(taxa = spp, get = "GET") (out <- phylomatic(taxa = spp, get = "POST", db = "itis")) plot(out) ## End(Not run)
## Not run: # Input taxonomic names taxa <- c("Poa annua", "Phlox diffusa", "Helianthus annuus") tree <- phylomatic(taxa=taxa, get = 'POST') plot(tree, no.margin=TRUE) # Genus names taxa <- c("Poa", "Phlox", "Helianthus") tree <- phylomatic(taxa=taxa, storedtree='R20120829', get='POST') plot(tree, no.margin=TRUE) # Lots of names taxa <- c("Poa annua", "Collomia grandiflora", "Lilium lankongense", "Phlox diffusa", "Iteadaphne caudata", "Gagea sarmentosa", "Helianthus annuus") tree <- phylomatic(taxa=taxa, get = 'POST') plot(tree, no.margin=TRUE) # Don't clean - clean=TRUE is default (tree <- phylomatic(taxa=taxa, clean = FALSE)) ## with clean=FALSE, you can get non-splitting nodes, which you ## need to collpase before plotting library('ape') plot(collapse.singles(tree), no.margin=TRUE) # Output NeXML format taxa <- c("Gonocarpus leptothecus", "Gonocarpus leptothecus", "Lilium lankongense") out <- phylomatic(taxa=taxa, get = 'POST', outformat = "nexml") cat(out) # Lots of names, note that when you have enough names (number depends on length of individual # names, so there's no per se rule), you will get an error when using `get='GET'`, # when that happens use `get='POST'` library("taxize") spp <- names_list("species", 500) # phylomatic(taxa = spp, get = "GET") (out <- phylomatic(taxa = spp, get = "POST", db = "itis")) plot(out) ## End(Not run)
Use Phylomatic locally - ideal for large queries
phylomatic_local( taxa, taxnames = TRUE, storedtree = "R20120829", db = "apg", lowercase = FALSE, nodes = FALSE, verbose = TRUE )
phylomatic_local( taxa, taxnames = TRUE, storedtree = "R20120829", db = "apg", lowercase = FALSE, nodes = FALSE, verbose = TRUE )
taxa |
(character) Phylomatic format input of taxa names. required |
taxnames |
If |
storedtree |
One of R20120829 (Phylomatic tree R20120829 for plants), smith2011 (Smith 2011, plants), binindaemonds2007 (Bininda-Emonds 2007, mammals), or zanne2014 (Zanne et al. 2014, plants). Default: R20120829 |
db |
(character) One of "ncbi", "itis", or "apg". Default: apg |
lowercase |
(logical) Convert all chars in taxa file to lowercase.
Default: |
nodes |
(logical) label all nodes with default names.
Default: |
verbose |
(logical) Print messages. Default: |
uses phylocomr::ph_phylomatic()
under the hood
This function uses Phylomatic via Phylocom using the
phylocomr package. The interface is slightly different from
phylomatic()
: there's no tree by URL available, and some of the
parameters are not included here.
If you set taxnames = FALSE
, you need to pass in a character
vector, with each element like this example:
"asteraceae/taraxacum/taraxacum_officinale"
, of the form
"family/genus/genus_specfic epithet"
Newick formatted tree as phylo
object
## Not run: library('ape') # Input taxonomic names taxa <- c("Poa annua", "Phlox diffusa", "Helianthus annuus") (tree <- phylomatic_local(taxa)) plot(collapse.singles(tree), no.margin=TRUE) taxa <- c("Poa annua", "Collomia grandiflora", "Lilium lankongense", "Phlox diffusa", "Iteadaphne caudata", "Gagea sarmentosa", "Helianthus annuus") (tree <- phylomatic_local(taxa)) plot(collapse.singles(tree), no.margin=TRUE) library("taxize") spp <- names_list("species", 500) length(spp) (tree <- phylomatic_local(spp)) ## End(Not run)
## Not run: library('ape') # Input taxonomic names taxa <- c("Poa annua", "Phlox diffusa", "Helianthus annuus") (tree <- phylomatic_local(taxa)) plot(collapse.singles(tree), no.margin=TRUE) taxa <- c("Poa annua", "Collomia grandiflora", "Lilium lankongense", "Phlox diffusa", "Iteadaphne caudata", "Gagea sarmentosa", "Helianthus annuus") (tree <- phylomatic_local(taxa)) plot(collapse.singles(tree), no.margin=TRUE) library("taxize") spp <- names_list("species", 500) length(spp) (tree <- phylomatic_local(spp)) ## End(Not run)
Get family names to make Phylomatic input object, and output input string to Phylomatic for use in the function phylomatic
phylomatic_names(taxa, format = "isubmit", db = "ncbi", ...)
phylomatic_names(taxa, format = "isubmit", db = "ncbi", ...)
taxa |
quoted tsn number (taxonomic serial number) |
format |
output format, isubmit (you can paste in to the Phylomatic website), or 'rsubmit' to use in fxn phylomatic_tree |
db |
One of "ncbi", "itis", or "apg". if you use "apg", no HTTP requests are made (no internet connection needed), whereas if you use "ncbi" or "itis" you do need an internet connection. IMPORTANT: see Authentication below if using "ncbi". |
... |
curl options passed on to |
string (e.g., "pinaceae/pinus/pinus_contorta"), in Phylomatic submission format
NCBI Entrez doesn't require that you use an API key, but you get
higher rate limit with a key, from 3 to 10 requests per second, so do
get one. Run taxize::use_entrez()
or see
https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/
for instructions.
NCBI API key handling logic is done inside of the taxize
package, used
inside this function.
Save your API key with the name ENTREZ_KEY
as an R option in your
.Rprofile
file, or as environment variables in either your .Renviron
file or .bash_profile
file, or .zshrc
file (if you use oh-my-zsh) or
similar. See Startup for help on R options and environment
variables. You cannot pass in your API key in this function.
Remember to restart your R session (and to start a new shell window/tab if you're using the shell) to take advantage of the new R options or environment variables.
We strongly recommend using environment variables over R options.
Note that if you don't have an ENTREZ_KEY set, you'll get a message about it, but only once during each function call. That is, there can be of these messages per R session, across function calls.
## Not run: mynames <- c("Poa annua", "Salix goodingii", "Helianthus annuus") phylomatic_names(taxa = mynames, format='rsubmit') phylomatic_names(mynames, format='rsubmit', db="apg") phylomatic_names(mynames, format='isubmit', db="ncbi") phylomatic_names(mynames, format='isubmit', db="apg") ## End(Not run)
## Not run: mynames <- c("Poa annua", "Salix goodingii", "Helianthus annuus") phylomatic_names(taxa = mynames, format='rsubmit') phylomatic_names(mynames, format='rsubmit', db="apg") phylomatic_names(mynames, format='isubmit', db="ncbi") phylomatic_names(mynames, format='isubmit', db="apg") ## End(Not run)
Phylogenies to use with phylomatic
A list with 4 character strings:
R20120829 - 2401 tips, 1801 internal nodes
binindaemonds2007 - 4510 tips, 2108 internal nodes
zanne2014 - 31749 tips, 31748 internal nodes
smith2011 - 55473 tips, 55338 internal nodes
phylocom
Run Phylocom's bladj from R
rbladj(tree, ages)
rbladj(tree, ages)
tree |
(character/phylo) One of: phylogeny as a newick string (will be
written to a temp file) - OR path to file with a newick
string - OR a an ape |
ages |
(data.frame/character) ages data.frame, or path to an ages file. required. |
uses phylocomr::ph_bladj()
under the hood
Newick formatted tree as phylo
object
## Not run: library("phylocomr") # make an ages data.frame ages_df <- data.frame( a = c('malpighiales','eudicots','ericales_to_asterales','plantaginaceae', 'malvids', 'poales'), b = c(81, 20, 56, 76, 47, 71) ) # read phylogeny file as a string phylo_file <- system.file("examples/phylo_bladj", package = "phylocomr") phylo_str <- readLines(phylo_file) # Run Bladj, returns phylo object (x <- rbladj(tree = phylo_str, ages = ages_df)) # load ape and plot tree library(ape) plot(x) ## End(Not run)
## Not run: library("phylocomr") # make an ages data.frame ages_df <- data.frame( a = c('malpighiales','eudicots','ericales_to_asterales','plantaginaceae', 'malvids', 'poales'), b = c(81, 20, 56, 76, 47, 71) ) # read phylogeny file as a string phylo_file <- system.file("examples/phylo_bladj", package = "phylocomr") phylo_str <- readLines(phylo_file) # Run Bladj, returns phylo object (x <- rbladj(tree = phylo_str, ages = ages_df)) # load ape and plot tree library(ape) plot(x) ## End(Not run)
These names are from http://www.theplantlist.org/, collected
on 2015-11-11, and are from version 1.1 of their data. This data is
used in the function phylomatic_names()
A data frame with 23,801 rows and 2 variables:
family: family name
genus: genus name