Getting taxonomic information

The classification function retrieves the taxonmic hierarchy for a given taxon using one of the following databases, which need to be specified using the db = argument:

…plus a few more.

Let’s try this in practice:

library(taxize)
classification("Podocarpus totara", db = "itis")
## 
## Retrieving data for taxon 'Podocarpus totara'
## $`Podocarpus totara`
##                 name          rank     id
## 1            Plantae       kingdom 202422
## 2      Viridiplantae    subkingdom 954898
## 3       Streptophyta  infrakingdom 846494
## 4        Embryophyta superdivision 954900
## 5       Tracheophyta      division 846496
## 6    Spermatophytina   subdivision 846504
## 7          Pinopsida         class 500009
## 8            Pinidae      subclass 954916
## 9            Pinales         order 500028
## 10     Podocarpaceae        family  18050
## 11        Podocarpus         genus 183488
## 12 Podocarpus totara       species 505863
## 
## attr(,"class")
## [1] "classification"
## attr(,"db")
## [1] "itis"

Including Plots

You can also create phylogenetic trees:

## 
## Retrieving data for taxon 'Dacrycarpus dacrydioides'
## 
## Retrieving data for taxon 'Dacrydium cupressinum'
## 
## 
## More than one GBIF ID found for taxon 'Dacrydium cupressinum'!
## 
##             Enter rownumber of taxon (other inputs will return 'NA'):
##    gbifid                         scientificname    rank   status
## 1 8483117     Dacrydium cupressinum Couper, 1960 species ACCEPTED
## 2 5286163 Dacrydium cupressinum Sol. ex G.Forst. species ACCEPTED
## 3 8607809             Dacrydium cupressinum Sol. species  SYNONYM
## 4 7641927    Dacrydium cupressinum Sol. ex Lamb. species DOUBTFUL
##   matchtype
## 1     EXACT
## 2     EXACT
## 3     EXACT
## 4     EXACT
## 
## Returned 'NA'!
## 
## Retrieving data for taxon 'Podocarpus totara'
## 
## 
## More than one GBIF ID found for taxon 'Podocarpus totara'!
## 
##             Enter rownumber of taxon (other inputs will return 'NA'):
##    gbifid                     scientificname    rank   status matchtype
## 1 5286079 Podocarpus totara G.Benn. ex D.Don species ACCEPTED     EXACT
## 2 8577017          Podocarpus totara G.Benn. species  SYNONYM     EXACT
## 
## Returned 'NA'!
## 
## Retrieving data for taxon 'Phyllocladus trichomanoides'
## 
## Retrieving data for taxon 'Beilschmiedia tawa'
## 
## Retrieving data for taxon 'Weinmannia racemosa'
## 
## Retrieving data for taxon 'Vitex lucens'
## Removed species without classification.

In addition to this information, we can retrieve all taxa downstream of the search taxon using the col_children() or the col_downstream() functions.

all_podocarpus <- col_children(name = "Podocarpus")
nrow(all_podocarpus$Podocarpus) # 100 described Podocarpus species
## [1] 100
podo_gen <- col_downstream(name = "Podocarpaceae", downto = "genus")
## 
podo_gen
## $Podocarpaceae
##                        childtaxa_id childtaxa_name childtaxa_rank
## 1  2dd0c65b3c33a57d768f03b33c8729ec       Acmopyle          genus
## 2  901ce3f29d7fbc647f3072c7f2efda5d     Afrocarpus          genus
## 3  1f28df21c2d1b546ca78b3b47e0a1c1b    Dacrycarpus          genus
## 4  2bd99ffd2c9029259a8cbb9fd4e8dee4      Dacrydium          genus
## 5  150a08534d306fdb6024644dc3c5caf4  Falcatifolium          genus
## 6  4c748fb926aa8ab1428697fea9eff6a2     Halocarpus          genus
## 7  c2396985cbf6377ee374e21a229976c1  Lagarostrobos          genus
## 8  a68d78c85d98794bdd696ab8e37fc329  Lepidothamnus          genus
## 9  9a636097941a72573b45feeacbdbec29         Manoao          genus
## 10 c50d580706753c9e254b6bcb7fb31662   Microcachrys          genus
## 11 e4c3cb4a2b95a43b6812f68a3b00a373         Nageia          genus
## 12 e60341d91c97dac040da002ef662d54d    Parasitaxus          genus
## 13 79d184e8e230f0411636a6529a1ae1fc   Pherosphaera          genus
## 14 f35ee0ccc4a7c160a500606773244499     Podocarpus          genus
## 15 a9be4d7e9401f5e1259e7da133de36bd    Prumnopitys          genus
## 16 4255166b5d674489032bd3a30aa434c1   Retrophyllum          genus
## 17 84b7f64e6c01b90be5b8a81c9cee9271    Saxegothaea          genus
## 18 523cf021db8b59989f1178c0c00656b9    Sundacarpus          genus
nrow(podo_gen$Podocarpaceae) # 18 genera within Podocarpaceae
## [1] 18

We can also get the common names associated with a scientific name or the other way around:

sci2comm("Dacrycarpus dacrydioides")
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## $`Dacrycarpus dacrydioides`
## [1] "kahikatea"                     "kahika"                       
## [3] "white pine"                    "Podocarpo della Nuova Zelanda"
## [5] "kahikatea"                     "Kai"                          
## [7] "kahika"                        "katea"                        
## [9] "koroi"
sci2comm("Geniostoma ligustrifolium")
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## Using default key: Please get your own API key at http://eol.org/users/register
## $`Geniostoma ligustrifolium`
## [1] "Papa"         "hangehange"   "hengahenga"   "pahengahenga"
## [5] "papahenga"    "whangewhange"
comm2sci("kahikatea")
## Using default key: Please get your own API key at http://eol.org/users/register
## $kahikatea
## [1] "Dacrycarpus dacrydioides (A. Rich.) de Laub."
## [2] "Dacrycarpus dacrydioides (A. Rich.) de Laub."
comm2sci("rimu")
## Using default key: Please get your own API key at http://eol.org/users/register
## $rimu
## [1] "Lepidothamnus laxifolius (Hook. f.) Quinn"
## [2] "Dacrydium cupressinum Sol. ex G. Forst."  
## [3] "Dacrydium cupressinum Sol. ex G. Forst."  
## [4] "Dacrydium cupressinum Sol. ex G. Forst."  
## [5] "Lepidothamnus fonkii Phil."               
## [6] "Umbonichiton rimu"                        
## [7] "Paracharopa rimu Climo, 1985"             
## [8] "Plectus sp. Rimu"

Apart from that, we can query the IUCN (International Union for Conservation of Nature) database to search for the conservation status of a certain species.

# get_iucn(x = "Beilschmiedia tawa")
# get_iucn(x = "Branta canadensis")
# get_iucn(x = as.iucn("22732"))
# iucn_summary(x = "Beilschmiedia tawa")

We can also retrieve the Unique Identifier (UID) of a taxon from NCBI taxonomy browser.

get_uid(sciname = "Prionoplus reticularis")
## No ENTREZ API key provided
## See https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/
## 
## Retrieving data for taxon 'Prionoplus reticularis'
## [1] "641891"
## attr(,"class")
## [1] "uid"
## attr(,"match")
## [1] "found"
## attr(,"multiple_matches")
## [1] FALSE
## attr(,"pattern_match")
## [1] FALSE
## attr(,"uri")
## [1] "https://www.ncbi.nlm.nih.gov/taxonomy/641891"

Furthermore, we can query the synonyms of a taxonomic name.

synonyms("Podocarpus totara", db = "col")
## 
## Retrieving data for taxon 'Podocarpus totara'
## 
## 
## More than one colid found for taxon 'Podocarpus totara'!
## 
##             Enter rownumber of taxon (other inputs will return 'NA'):
##                           name    rank                            colid
## 1            Podocarpus totara species dad52b52e2a7e6ae26e0c072b7eacf31
## 2 Podocarpus totara waihoensis species dad52b52e2a7e6ae26e0c072b7eacf31
## 3    Podocarpus totara alpinus species 2fa428d9ad8c89658d84099dcc82a8a7
## 4     Podocarpus totara hallii species 3499a92191238e8ac99927f96f1fe22f
## 5 Podocarpus totara waihoensis species dad52b52e2a7e6ae26e0c072b7eacf31
##     name_status kingdom        family                acc_name
## 1 accepted name Plantae Podocarpaceae                    <NA>
## 2       synonym    <NA>          <NA>       Podocarpus totara
## 3       synonym    <NA>          <NA>    Podocarpus lawrencei
## 4       synonym    <NA>          <NA> Podocarpus cunninghamii
## 5       synonym    <NA>          <NA>       Podocarpus totara
## 
## Returned 'NA'!
## $`Podocarpus totara`
## [1] NA
## 
## attr(,"class")
## [1] "synonyms"
## attr(,"db")
## [1] "col"

Phylogenetic trees

The ape package (Analysis of Phylogenetics and Evolution) is the core package for phylogenetic work. It contains simulation tools, that allow the construction of artifical phylogenetic trees.

library(ape)
tree <- rtree(n = 20)
plot(tree, edge.width = 2)

The object ‘tree’ is list of class phylo which contains four components:

str(tree)
## List of 4
##  $ edge       : int [1:38, 1:2] 21 22 23 23 22 24 24 25 25 26 ...
##  $ tip.label  : chr [1:20] "t11" "t3" "t6" "t7" ...
##  $ edge.length: num [1:38] 0.306 0.91 0.656 0.207 0.778 ...
##  $ Nnode      : int 19
##  - attr(*, "class")= chr "phylo"
##  - attr(*, "order")= chr "cladewise"

Small trees may be written by hand in “parenthetic format”, which is called Newick format.

tree <- read.tree(text = "((((A,B), C), (D,E)),F);")
plot(tree, type = "cladogram", edge.width = 2)

plot(tree, edge.width = 2)

We can also add node or tip labels and even coloured symbols to the tree.

plot(tree, edge.width = 2, label.offset = 0.2)
nodelabels()
tiplabels()

plot(tree, label.offset = 0.7, adj = 0)
cols <- rep(c("blue", "red2"), each = 3)
tiplabels(pch = 21, col = "black", bg = cols, adj = 1, cex = 2)

We can also swap things around, e.g. clades (D, E) and (A, B, C). Their most recent common ancestor is found at node 8.

rot.phy <- rotate(tree, node = 8)
plot(rot.phy, label.offset = 0.2)
nodelabels()          
tiplabels()