Dyntaxa

Dyntaxa is a taxonomic database of Swedish organisms hosted at SLU Artdatabanken, providing information on their names and relationships. The database includes details such as the current classification, recommended names, and commonly used synonymous or misapplied names. Dyntaxa is continuously updated with new species for Sweden, new Swedish names, synonymous scientific names, and new data on relationships. The data in Dyntaxa serves as the foundation and framework for taxonomic information in SHARK. It can be accessed via a web interface or through the API, as demonstrated in this tutorial using SHARK4R. Please note that the authors of SHARK4R are not affiliated with Dyntaxa.

Getting Started

Installation

You can install the package from GitHub using the devtools package:

# install.packages("devtools")
devtools::install_github("sharksmhi/SHARK4R",
                         dependencies = TRUE)

Load the SHARK4R, tibble and dplyr libraries:

library(SHARK4R)
library(tibble)
library(dplyr)
suppressPackageStartupMessages({
  library(SHARK4R)
  library(tibble)
  library(dplyr)
})

Retrieve Taxonony Table from SHARK

Taxon and data tables can be retrieved with the same filtering options available in SHARK. To see the available filtering options, please refer to get_shark_options and the Retrieve Data From SHARK tutorial.

# Retrieve taxonomy reports for phytoplankton between 2019 and 2020
shark_taxon <- get_shark_data(tableView = "report_taxon",
                              fromYear = 2019,
                              toYear = 2020,
                              dataTypes = "Phytoplankton",
                              verbose = FALSE)

# Print data
print(shark_taxon)

# Retrieve all phytoplankton data from July 2015
shark_data <- get_shark_data(tableView = "sharkdata_phytoplankton",
                             fromYear = 2015, 
                             toYear = 2015,
                             months = 7,
                             dataTypes = c("Phytoplankton"),
                             verbose = FALSE)

# Print data
print(shark_data)

Dyntaxa API Key

Dyntaxa requires a subscription key to access its API. To obtain your own key, sign up for the taxonomy product at the SLU Swedish Species Information Centre“s Developer Portal. In the example below, the key is retrieved from an environment variable.

# Retrieve the API key
dyntaxa_key <- Sys.getenv("DYNTAXA_KEY")

Update SHARK Taxonomy Data

If the taxonomic data downloaded from SHARK are outdated, they can be updated to the latest Dyntaxa information using SHARK4R. Alternatively, data can be retrieved from WoRMS. For details, see the WoRMS Tutorial.

# Update taxonomy information for the retrieved phytoplankton data
updated_taxonomy <- update_dyntaxa_taxonomy(
  dyntaxa_ids = shark_data$dyntaxa_id,
  subscription_key = dyntaxa_key,
  verbose = FALSE)

# Print the updated taxonomy data
print(updated_taxonomy)

Match Taxon Names

# Randomly select 10 phytoplankton taxa from shark_taxon
taxon_names <- sample(shark_taxon$scientific_name, size = 10)

# Match taxon_names with Dyntaxa API
matches <- match_taxon_name(taxon_names = taxon_names, 
                            subscription_key = dyntaxa_key, 
                            multiple_options = FALSE,
                            verbose = FALSE)

# Print the result
tibble(matches)

Retrieve Taxonomic information

Taxonomic records can be retrieved for indivudual taxa using the get_dyntaxa_records function.

# Get all Dyntaxa IDs
dyntaxa_id <- unique(matches$taxon_id)

# Remove potential NAs
dyntaxa_id <- dyntaxa_id[!is.na(dyntaxa_id)]

# Get Dyntaxa records
dyntaxa_records <- get_dyntaxa_records(taxon_ids = dyntaxa_id,
                                       subscription_key = dyntaxa_key)

# Print records
tibble(dyntaxa_records)

Retrieve Parent IDs

All parent taxa above the Dyntaxa ID can be retrieved using the get_dyntaxa_parent_ids function.

# Get all parents
parents_id <- get_dyntaxa_parent_ids(taxon_ids = dyntaxa_id, 
                                     subscription_key = dyntaxa_key,
                                     verbose = FALSE)

# List the IDs
print(parents_id)

Construct Complete Taxonomic Table

A comprehensive taxonomic table, including related taxa, can be created with the construct_dyntaxa_table function. Use the add_synonyms parameter to include synonyms, and the add_parents and add_descendants parameters to include parent and descendant taxa, respectively. If Taxon IDs are missing from the DwC-A export (e.g. species complex and pseudotaxon), they can be matched using the add_missing_taxa argument. Additionally, complete hierarchy information can be added as a string of parent taxa separated by "-" using the add_hierarchy argument.

# Retrieve complete taxonomic table (including parents and descendants)
taxonomy_table <- construct_dyntaxa_table(taxon_ids = dyntaxa_id, 
                                          subscription_key = dyntaxa_key, 
                                          shark_output = FALSE, 
                                          add_parents = TRUE,
                                          add_synonyms = TRUE, 
                                          add_descendants = TRUE,
                                          add_descendants_rank = "genus",
                                          add_missing_taxa = FALSE,
                                          add_hierarchy = FALSE,
                                          verbose = FALSE)

# Print the taxonomy table as a tibble
tibble(taxonomy_table)

Citation

# Print citation
citation("SHARK4R")


sharksmhi/SHARK4R documentation built on Jan. 9, 2025, 5:15 p.m.