When working with biodiversity data, it is important to verify taxonomic names with an authoritative list and correct any out-of-date names or names with typos. The ‘APCalign’ package simplifies this process by:
The latest version of ‘APCalign’ should be available on CRAN and can
be installed using install.packages("APCalign").
You can alternatively install the current developmental version using
Alternatively, our app, is available at app.austraits.org/APCalign-app
To demonstrate how to use ‘APCalign’, we will use an example dataset
gbif_lite which is documented in
?gbif_lite
dim(gbif_lite)
#> [1] 129 7
gbif_lite |> print(n = 6)
#> # A tibble: 129 × 7
#> species infraspecificepithet taxonrank decimalLongitude decimalLatitude scientificname verbatimscientificname
#> <chr> <chr> <chr> <dbl> <dbl> <chr> <chr>
#> 1 Tetratheca cili… <NA> SPECIES 145. -37.4 Tetratheca ci… Tetratheca ciliata
#> 2 Peganum harmala <NA> SPECIES 139. -33.3 Peganum harma… Peganum harmala
#> 3 Calotis multica… <NA> SPECIES 115. -24.3 Calotis multi… Calotis multicaulis
#> 4 Leptospermum tr… <NA> SPECIES 151. -34.0 Leptospermum … Leptospermum trinervi…
#> 5 Lepidosperma la… <NA> SPECIES 142. -37.3 Lepidosperma … Lepidosperma laterale
#> 6 Enneapogon poly… <NA> SPECIES 129. -17.8 Enneapogon po… Enneapogon polyphyllus
#> # ℹ 123 more rowsThe first step is to retrieve the entire APC and APNI name databases
and store them locally as taxonomic resources. We achieve this using
load_taxonomic_resources().
There are two versions of the databases that you can retrieve with
the stable_or_current_data argument. Calling:
stable will retrieve the most recent, archived version
of the databases from our GitHub
releases. This is set as the default option.current will retrieve the up-to-date databases directly
from the APC and APNI website.Note that the databases are quite large so the initial retrieval of
stable versions will take a few minutes. Once the taxonomic
resources have been stored locally, subsequent retrievals will take less
time. Retrieving current resources will always take longer
since it is accessing the latest information from the website. Check out
our reproducibility
article to learn more about the versions of the APC and APNI databases
and how they are stored.
# Benchmarking the retrieval of `stable` or `current` resources
stable_start_time <- Sys.time()
stable_resources <- load_taxonomic_resources(stable_or_current_data = "stable")
stable_end_time <- Sys.time()
current_start_time <- Sys.time()
current_resources <- load_taxonomic_resources(stable_or_current_data = "current")
current_end_time <- Sys.time()
# Compare times
stable_end_time - stable_start_timeFor a more reproducible workflow, we recommend specifying the exact
stable version you want to use.
Now we can query our taxonomic names against the taxonomic resources
we just retrieved using create_taxonomic_update_lookup().
This all-in-one function will:
accepted_name when available, and otherwise providing an
APNI name or a name where only a genus-level alignment is possible.If you would like to learn more about each of these step, take a look at the section Closer look at name alignment and updating with ‘APCalign’
library(dplyr)
updated_gbif_names <- gbif_lite |>
pull(species) |>
create_taxonomic_update_lookup(resources = resources)
#> Checking alignments of 121 taxa
#> -> of these 113 names have a perfect match to an accepted scientific name in the APC, and 6 names have a perfect match to a synonym in the APC.
#> Alignments being sought for remaining names.
#> Summary of 121 names:
#> -> 120 aligned to a species or infraspecific taxon (120 in the APC, 0 in the APNI only)
#> -> 1 aligned only to a genus and 0 only to a family
#> -> 0 could not be aligned
#> -> 4 aligned names were updated to a different name (e.g. a synonym to its accepted name, or an outdated genus to the current one)
#> -> 14 names could refer to more than one currently accepted taxon. With `taxonomic_splits = "most_likely_species"`, `suggested_name` gives the most likely species and lists the alternatives in square brackets.
updated_gbif_names |>
print(n = 6)
#> # A tibble: 129 × 13
#> original_name aligned_name accepted_name suggested_name genus taxon_rank taxonomic_dataset taxonomic_status
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Tetratheca ciliata Tetratheca c… Tetratheca c… Tetratheca ci… Tetr… species APC accepted
#> 2 Peganum harmala Peganum harm… Peganum harm… Peganum harma… Pega… species APC accepted
#> 3 Calotis multicaulis Calotis mult… Calotis mult… Calotis multi… Calo… species APC accepted
#> 4 Leptospermum trinervium Leptospermum… Leptospermum… Leptospermum … Lept… species APC accepted
#> 5 Lepidosperma laterale Lepidosperma… Lepidosperma… Lepidosperma … Lepi… species APC accepted
#> 6 Enneapogon polyphyllus Enneapogon p… Enneapogon p… Enneapogon po… Enne… species APC accepted
#> # ℹ 123 more rows
#> # ℹ 5 more variables: scientific_name <chr>, aligned_reason <chr>, update_reason <chr>, number_of_collapsed_taxa <dbl>,
#> # chars_changed <int>The original_name is the taxon name used in your
original data. The aligned_name is the taxon name we used
to link with the APC to identify any synonyms. The
accepted_name is the currently, accepted taxon name used by
the Australian Plant Census. The suggested_name is the best
possible name option for the original_name.
‘APCalign’ can also provide the state/territory distribution for established status (native/introduced) from the APC.
We can access the established status data by state/territory using
create_species_state_origin_matrix()
You can specify to include infrataxa (subspecies, varieties and
forms) using include_infrataxa = TRUE, or generate
statistics just for species using
include_infrataxa = FALSE.
# Retrieve status data by state/territory
status_matrix <- create_species_state_origin_matrix(resources = resources, include_infrataxa = TRUE)Here is a breakdown of all possible values for
origin
library(janitor)
# Obtain unique values for establishment status
status_matrix |>
tidyr::pivot_longer(-c(family, species, taxon_ID)) |>
filter(value != "not present") |>
distinct(value)
#> # A tibble: 9 × 1
#> value
#> <chr>
#> 1 native
#> 2 naturalised
#> 3 doubtfully naturalised
#> 4 native and naturalised
#> 5 formerly naturalised
#> 6 presumed extinct
#> 7 uncertain origin
#> 8 native and uncertain origin
#> 9 native and doubtfully naturalisedstatus_matrix |> select(family, species, ACT:WA) |> print(n=20)
#> # A tibble: 31,074 × 10
#> family species ACT NSW NT Qld SA Tas Vic WA
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Acanthaceae Acanthus ebracteatus not present not pr… nati… nati… not … not … not … nati…
#> 2 Acanthaceae Acanthus ebracteatus subsp. ebarbatus not present not pr… nati… nati… not … not … not … nati…
#> 3 Acanthaceae Acanthus ilicifolius not present not pr… nati… nati… not … not … not … not …
#> 4 Acanthaceae Acanthus mollis not present natura… not … doub… natu… natu… natu… natu…
#> 5 Acanthaceae Andrographis paniculata not present not pr… natu… doub… not … not … not … not …
#> 6 Acanthaceae Asystasia alba not present not pr… not … not … not … not … not … not …
#> 7 Acanthaceae Asystasia australasica not present not pr… not … nati… not … not … not … not …
#> 8 Acanthaceae Asystasia gangetica not present natura… natu… natu… not … not … not … natu…
#> 9 Acanthaceae Asystasia gangetica subsp. gangetica not present not pr… natu… natu… not … not … not … natu…
#> 10 Acanthaceae Asystasia gangetica subsp. micrantha not present not pr… not … natu… not … not … not … not …
#> 11 Acanthaceae Asystasia sp. Flora of Australia (D.A.Powell 740) not present not pr… not … not … not … not … not … not …
#> 12 Acanthaceae Asystasia sp. Newcastle Bay (L.J.Brass 18671) not present not pr… not … nati… not … not … not … not …
#> 13 Acanthaceae Asystasia sp. Phosphate Hill (D.A.Powell 787) not present not pr… not … not … not … not … not … not …
#> 14 Acanthaceae Avicennia integra not present not pr… nati… not … not … not … not … not …
#> 15 Acanthaceae Avicennia marina not present native nati… nati… nati… not … nati… nati…
#> 16 Acanthaceae Avicennia marina subsp. australasica not present native not … nati… not … not … nati… not …
#> 17 Acanthaceae Avicennia marina subsp. eucalyptifolia not present not pr… nati… nati… not … not … not … nati…
#> 18 Acanthaceae Avicennia marina subsp. marina not present not pr… not … not … nati… not … not … nati…
#> 19 Acanthaceae Barleria cristata not present not pr… not … natu… not … not … not … not …
#> 20 Acanthaceae Barleria lupulina not present not pr… natu… natu… not … not … not … natu…
#> # ℹ 31,054 more rowsYou can also obtain the breakdown of species by established status
for a particular state/territory using
state_diversity_counts()
state_diversity_counts("NSW", resources = resources)
#> # A tibble: 7 × 3
#> origin state num_species
#> <chr> <chr> <int>
#> 1 doubtfully naturalised NSW 95
#> 2 formerly naturalised NSW 8
#> 3 native NSW 5986
#> 4 native and doubtfully naturalised NSW 2
#> 5 native and naturalised NSW 34
#> 6 naturalised NSW 1587
#> 7 presumed extinct NSW 9Using the established status data and state/territory information, we
can check if a plant taxa is a native using
native_anywhere_in_australia()
set.seed(1)
updated_gbif_names |>
filter(taxonomic_status == "accepted") |>
sample_n(1) |> # Choosing a random accepted species
pull(suggested_name) |> # Extracting this APC accepted name
native_anywhere_in_australia(resources = resources)
#> # A tibble: 1 × 2
#> species native_anywhere_in_aus
#> <chr> <chr>
#> 1 Sclerolaena birchii nativecreate_taxonomic_update_lookup is a simple, wrapper,
function for novice users that want to quickly check and standardise
taxon names. For more experienced users, you can take a look at the sub
functions align_taxa() and update_taxonomy()
to see how taxon names are processed, aligned and updated.
The function align_taxa will:
standardise_names,
strip_names and strip_names_extra standardise
infraspecific taxon designations and clean up punctuation and
whitespacestaxon_rank to which the name can be
resolved, based on its syntax.
genus sp. name, with additional
information/notes provided as part of the original name in square
brackets, as in Acacia sp. [skinny leaves] or
Acacia sp. [Broken Hill]taxonomic_dataset (APC or APNI) of each
name-alignment.Note that align_taxa does
not seek to update outdated taxonomy. That process occurs
during update_taxonomy process.
align_taxa instead aligns each name input to the closest
match amongst names documented by the APC and APNI.
library(dplyr)
aligned_gbif_taxa <- gbif_lite |>
pull(species) |>
align_taxa(resources = resources)
#> Checking alignments of 121 taxa
#> -> of these 113 names have a perfect match to an accepted scientific name in the APC, and 6 names have a perfect match to a synonym in the APC.
#> Alignments being sought for remaining names.
aligned_gbif_taxa |>
print(n = 6)
#> # A tibble: 129 × 8
#> original_name cleaned_name aligned_name taxonomic_dataset taxon_rank aligned_reason alignment_code chars_changed
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 Tetratheca ciliata Tetratheca … Tetratheca … APC species Exact match o… match_01c_acc… 0
#> 2 Peganum harmala Peganum har… Peganum har… APC species Exact match o… match_01c_acc… 0
#> 3 Calotis multicaulis Calotis mul… Calotis mul… APC species Exact match o… match_01c_acc… 0
#> 4 Leptospermum trine… Leptospermu… Leptospermu… APC species Exact match o… match_01c_acc… 0
#> 5 Lepidosperma later… Lepidosperm… Lepidosperm… APC species Exact match o… match_01c_acc… 0
#> 6 Enneapogon polyphy… Enneapogon … Enneapogon … APC species Exact match o… match_01c_acc… 0
#> # ℹ 123 more rowsFor every aligned_name, align_taxa() will
provide a aligned_reason which you can review as a table of
counts:
library(janitor)
aligned_gbif_taxa |>
pull(aligned_reason) |>
tabyl() |>
tibble()
#> # A tibble: 5 × 4
#> `pull(aligned_gbif_taxa, aligned_reason)` n percent valid_percent
#> <chr> <int> <dbl> <dbl>
#> 1 Exact match of taxon name to an APC-accepted canonical name once punctuation and filler w… 119 0.922 0.937
#> 2 Exact match of taxon name to an APC-known canonical name once punctuation and filler word… 6 0.0465 0.0472
#> 3 Exact match of the first two words of the taxon name to an APC-accepted canonical name (A… 1 0.00775 0.00787
#> 4 Exact match of the first word of the taxon name to an APC-accepted genus (APC/APNI versio… 1 0.00775 0.00787
#> 5 <NA> 2 0.0155 NAThere are arguments in align_taxa that allows you to
select which of the 54 matching algorithms are activated/deactivated and
the degree of fuzziness of the fuzzy matching function
fuzzy_matches turns fuzzy matching on / off (it
defaults to TRUE).fuzzy_abs_dist and fuzzy_rel_dist control
the degree of fuzzy matching (they default to
fuzzy_abs_dist = 3 &
fuzzy_rel_dist = 0.2).imprecise_fuzzy_matches turns imprecise fuzzy matching
on / off (it defaults to FALSE; for true it is set to
fuzzy_abs_dist = 5 &
fuzzy_rel_dist = 0.25).APNI_matches turns matches to the APNI list on/off (it
defaults to TRUE).identifier allows you to specify a text string that is
added to genus-level matches, indicating the site, study, etc
e.g. Acacia sp. [Blue Mountains]update_taxonomy() uses the information generated by
align_taxa() to, whenever possible, update names to
APC-accepted names.
updated_gbif_taxa <- aligned_gbif_taxa |>
update_taxonomy(resources = resources)
updated_gbif_taxa |>
print(n = 6)
#> # A tibble: 129 × 22
#> original_name aligned_name accepted_name suggested_name genus family taxon_rank taxonomic_dataset taxonomic_status
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Tetratheca cilia… Tetratheca … Tetratheca c… Tetratheca ci… Tetr… Elaeo… species APC accepted
#> 2 Peganum harmala Peganum har… Peganum harm… Peganum harma… Pega… Nitra… species APC accepted
#> 3 Calotis multicau… Calotis mul… Calotis mult… Calotis multi… Calo… Aster… species APC accepted
#> 4 Leptospermum tri… Leptospermu… Leptospermum… Leptospermum … Lept… Myrta… species APC accepted
#> 5 Lepidosperma lat… Lepidosperm… Lepidosperma… Lepidosperma … Lepi… Cyper… species APC accepted
#> 6 Enneapogon polyp… Enneapogon … Enneapogon p… Enneapogon po… Enne… Poace… species APC accepted
#> # ℹ 123 more rows
#> # ℹ 13 more variables: taxonomic_status_aligned <chr>, aligned_reason <chr>, update_reason <chr>, subclass <chr>,
#> # taxon_distribution <chr>, scientific_name <chr>, taxon_ID <chr>, taxon_ID_genus <chr>, scientific_name_ID <chr>,
#> # canonical_name <chr>, row_number <dbl>, number_of_collapsed_taxa <dbl>, chars_changed <int>The APC includes all previously recorded taxonomic names for a
current taxon concept, designating the currently-accepted name as
taxonomic_status: accepted, while previously used or
inappropriately used names for the taxon concept have alternative
taxonomic statuses documented (e.g. taxonomic synonym, orthographic
variant, misapplied).
The APC includes a column acceptedNameUsageID that
links a taxon name with an alternative taxonomic status to the current
taxon name, allowing outdated/inappropriately used names to be synced to
their current name.
Note: Names listed on the APNI but absent from the APC are
those that are designated as taxonomic_dataset: APNI by
APCalign. These are names that are currently
unknown by the APC. Over time, this list shrinks, as
taxonomists link ever more occasionally used name variants to an
APC-accepted taxon. However, for now, names listed only on the APNI
cannot be updated
update_taxonomy() divides names into lists based on the
taxon_rank and taxonomic_dataset assigned by
align_taxa, as each list requires different updating
algorithms.taxon_rank = species/infraspecific and
taxonomic_dataset = APC can be updated to an APC-accepted
name.suggested_name is provided, selecting
the accepted_name when available, and otherwise the
aligned_name, but with, if possible, an updated,
APC-accepted genus name.Taxonomic splits refers to instances where a single taxon concept
is subsequently split into multiple taxon concepts. For such taxa, when
the aligned_name is the “old” taxon concept name, it is
impossible to know which of the currently accepted taxon concepts the
name represents.
The function update_taxonomy includes an argument
taxonomic_splits, offering three alternative outputs for
taxon concepts that have been split.
most_likely_species is the default value, and
returns the accepted_name of the original taxon_concept;
alternative names are documented in square brackets as part of the
suggested name
(Acacia aneura [alternative possible names: Acacia minyura (pro parte misapplied) | Acacia paraneura (pro parte misapplied) | Acacia quadrimarginea (misapplied)]).
return_all returns all currently accepted names that
were split from the original taxon_concept; this leads to an increase in
the number of rows in the output table. (Acacia aneura, Acacia minyura
and Acacia paraneura are each output as a separate row, each with a
unique taxon_ID)
collapse_to_higher_taxon declares that for split
names, there is no way to be certain about which accepted name is
appropriate and therefore that the best possible match is at the genus
level; the accepted_name becomes Acacia sp.
and the suggested name documents the possible species-level names in
square brackets
(Acacia sp. [collapsed names: Acacia aneura (accepted) | Acacia minyura (pro parte misapplied) | Acacia paraneura (pro parte misapplied) | Acacia quadrimarginea (misapplied)]).
Only names that could be more than one taxon are collapsed: a name whose
usages all lead to one taxon is updated to it, under every option. Only
these two names change: taxon_rank, taxon_ID
and scientific_name stay those of the most likely taxon,
here Acacia aneura at species rank, as the output below
shows.
library(dplyr)
aligned_gbif_taxa |>
update_taxonomy(taxonomic_splits = "most_likely_species",
resources = resources) |>
filter(original_name == "Acacia aneura") # Subsetting Acacia aneura as an example
#> # A tibble: 1 × 22
#> original_name aligned_name accepted_name suggested_name genus family taxon_rank taxonomic_dataset taxonomic_status
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Acacia aneura Acacia aneura Acacia aneura Acacia aneura [a… Acac… Fabac… species APC accepted
#> # ℹ 13 more variables: taxonomic_status_aligned <chr>, aligned_reason <chr>, update_reason <chr>, subclass <chr>,
#> # taxon_distribution <chr>, scientific_name <chr>, taxon_ID <chr>, taxon_ID_genus <chr>, scientific_name_ID <chr>,
#> # canonical_name <chr>, row_number <dbl>, number_of_collapsed_taxa <dbl>, chars_changed <int>aligned_gbif_taxa |>
update_taxonomy(taxonomic_splits = "return_all",
resources = resources) |>
filter(original_name == "Acacia aneura") # Subsetting Acacia aneura as an example
#> # A tibble: 3 × 22
#> original_name aligned_name accepted_name suggested_name genus family taxon_rank taxonomic_dataset taxonomic_status
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Acacia aneura Acacia aneura Acacia aneura Acacia aneura Acac… Fabac… species APC accepted
#> 2 Acacia aneura Acacia aneura Acacia paraneura Acacia parane… Acac… Fabac… species APC accepted
#> 3 Acacia aneura Acacia aneura Acacia minyura Acacia minyura Acac… Fabac… species APC accepted
#> # ℹ 13 more variables: taxonomic_status_aligned <chr>, aligned_reason <chr>, update_reason <chr>, subclass <chr>,
#> # taxon_distribution <chr>, scientific_name <chr>, taxon_ID <chr>, taxon_ID_genus <chr>, scientific_name_ID <chr>,
#> # canonical_name <chr>, row_number <dbl>, number_of_collapsed_taxa <dbl>, chars_changed <int>aligned_gbif_taxa |>
update_taxonomy(taxonomic_splits = "collapse_to_higher_taxon",
resources = resources) |>
filter(original_name == "Acacia aneura") # Subsetting Acacia aneura as an example
#> # A tibble: 1 × 22
#> original_name aligned_name accepted_name suggested_name genus family taxon_rank taxonomic_dataset taxonomic_status
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Acacia aneura Acacia aneura Acacia sp. Acacia sp. [coll… Acac… Fabac… species APC accepted
#> # ℹ 13 more variables: taxonomic_status_aligned <chr>, aligned_reason <chr>, update_reason <chr>, subclass <chr>,
#> # taxon_distribution <chr>, scientific_name <chr>, taxon_ID <chr>, taxon_ID_genus <chr>, scientific_name_ID <chr>,
#> # canonical_name <chr>, row_number <dbl>, number_of_collapsed_taxa <dbl>, chars_changed <int>synonyms_for_accepted_names() compiles a table of all
outdated and misapplied names which once applied to an accepted taxon
name. The output can be in a condensed format, with the synonyms for an
accepted name appearing in a single cell, or in a long format, with a
separate row for each synonym. Both formats indicate each synonyms
“type” - nomenclatural_synonym,
taxonomic_synonym, orthographic_variant,
misapplied, etc. This function is particularly useful for
research applications where you know a currently accepted taxon name and
want to indicate part names that apply, to document the links or to
efficiently search the literature.
names_to_check <- c("Acacia aneura", "Banksia nivea", "Cardamine gunnii", "Stenocarpus sinuatus")
synonyms_for_accepted_names(resources = resources, accepted_names = names_to_check, collapse = TRUE)
#> # A tibble: 4 × 5
#> family accepted_name synonyms scientific_name accepted_name_usage_ID
#> <chr> <chr> <chr> <chr> <chr>
#> 1 Brassicaceae Cardamine gunnii Cardamine hirsuta var. debilis (taxonomic sy… Cardamine gunn… https://id.biodiversi…
#> 2 Fabaceae Acacia aneura Acacia aneura var. intermedia (taxonomic syn… Acacia aneura … https://id.biodiversi…
#> 3 Proteaceae Banksia nivea Dryandra nivea var. adscendens (taxonomic sy… Banksia nivea … https://id.biodiversi…
#> 4 Proteaceae Stenocarpus sinuatus Agnostus sinuatus (taxonomic synonym); Agnos… Stenocarpus si… https://id.biodiversi…synonyms_for_accepted_names(resources = resources, accepted_names = names_to_check, collapse = FALSE)
#> # A tibble: 25 × 7
#> family accepted_name synonym taxonomic_status scientific_name accepted_name_usage_ID taxon_ID
#> <chr> <chr> <chr> <fct> <chr> <chr> <chr>
#> 1 Brassicaceae Cardamine gunnii Cardamine hirsuta var… taxonomic synon… Cardamine gunn… https://id.biodiversi… https:/…
#> 2 Brassicaceae Cardamine gunnii Cardamine hirsuta var… taxonomic synon… Cardamine gunn… https://id.biodiversi… https:/…
#> 3 Brassicaceae Cardamine gunnii Cardamine gunnii, typ… nomenclatural s… Cardamine gunn… https://id.biodiversi… https:/…
#> 4 Brassicaceae Cardamine gunnii Cardamine heterophyll… nomenclatural s… Cardamine gunn… https://id.biodiversi… https:/…
#> 5 Brassicaceae Cardamine gunnii Cardamine heterophylla nomenclatural s… Cardamine gunn… https://id.biodiversi… https:/…
#> 6 Brassicaceae Cardamine gunnii Cardamine debilis misapplied Cardamine gunn… https://id.biodiversi… https:/…
#> 7 Fabaceae Acacia aneura Acacia aneura var. in… taxonomic synon… Acacia aneura … https://id.biodiversi… https:/…
#> 8 Fabaceae Acacia aneura Racosperma aneurum va… taxonomic synon… Acacia aneura … https://id.biodiversi… https:/…
#> 9 Fabaceae Acacia aneura Acacia aneura var. (N… taxonomic synon… Acacia aneura … https://id.biodiversi… https:/…
#> 10 Fabaceae Acacia aneura Acacia aneura var. (T… taxonomic synon… Acacia aneura … https://id.biodiversi… https:/…
#> # ℹ 15 more rows