| Type: | Package |
| Title: | Functional Guilds, Invasion Status, Endemism, and Rarity of Ants |
| Version: | 0.3.0 |
| Date: | 2026-12-01 |
| Description: | Provides functions for the analysis of ant communities, aiming to standardize workflows in myrmecology. The package automates the assignment of species to functional guilds based on trophic strategies, feeding habits, and foraging behavior, using established classification frameworks (Silva et al., 2015 <doi:10.7476/9788574554419>; Silvestre et al., 2003 <isbn:9588151236>; Delabie et al., 2000 <doi:10.1590/S0101-81751999000200014>), and also includes a novel classification system implemented within the package, developed from ant species occurring in urban environments. It also includes routines to flag exotic species in Brazil (Wong et al., 2023 <doi:10.1016/j.cub.2022.12.020>; Vieira, 2025, unpublished master's thesis), identify endemic species (Silva et al., 2025 <doi:10.37885/250920259>), and classify species rarity and rarity forms of the Atlantic Forest (Silva et al., 2024 <doi:10.1016/j.biocon.2024.110640>). The package reduces manual effort and improves reproducibility, supporting research and biodiversity management of Neotropical ant communities. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/cogdebora/AntClassify |
| BugReports: | https://github.com/cogdebora/AntClassify/issues |
| Depends: | R (≥ 3.5) |
| Imports: | curl, dplyr, ggplot2, jsonlite, magrittr, rlang, scales, stats, stringr |
| Suggests: | knitr, rgbif, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyData: | true |
| NeedsCompilation: | no |
| RoxygenNote: | 7.3.3 |
| Packaged: | 2026-12-01 21:07:17 UTC; 55119 |
| Author: | Débora C. O. Gonçalves [aut, cre], Nathalia S. Silva [aut], Rony P. S. Almeida [aut], Lívia P. Prado [aut], Maria S. C. Morini [aut] |
| Maintainer: | Débora C. O. Gonçalves <debora_cog@outlook.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-12-01 21:20:03 UTC |
Ant community example
Description
A sample community matrix of ant species abundances with 3 sites and 6 species. Rows represent sites, columns represent species.
Usage
data(ant_community)
Format
A data frame with 3 rows and 6 columns:
- Atta sexdens
abundance of Atta sexdens
- Camponotus atriceps
abundance of Camponotus atriceps
- Pheidole megacephala
abundance of Pheidole megacephala
- Wasmannia auropunctata
abundance of Wasmannia auropunctata
- Solenopsis saevissima
abundance of Solenopsis saevissima
- Nylanderia fulva
abundance of Nylanderia fulva
Source
Simulated data for package examples.
Examples
data(ant_community)
head(ant_community)
AntClassify Full Ecological Pipeline
Description
Runs all ecological classification functions of the package.
Usage
antclassify(
comm,
verbose = TRUE,
plot = TRUE,
validate = TRUE,
delay = 0.5,
ask = TRUE,
preferred_guilds = NULL
)
Arguments
comm |
Community matrix (samples x species). Species names as columns, samples as rows. |
verbose |
Logical; if TRUE, displays progress messages. |
plot |
Logical; if TRUE, displays guild proportion plots (passed to assign_guild_ants). |
validate |
Logical; if TRUE, validates species names using GBIF. |
delay |
Numeric; seconds between API calls (if validate = TRUE). |
ask |
Logical; if TRUE (default), allows interactive resolution of ambiguous guild classifications in |
preferred_guilds |
Optional named list to specify preferred guilds for genera with multiple options. Passed to |
Value
A list containing results from all analyses (guilds, exotic, endemic, rarity).
Examples
## Not run:
# Load the built-in example dataset
data(ant_community)
# Run the full pipeline (validation disabled for speed)
results <- antclassify(ant_community, validate = FALSE, plot = FALSE)
# Inspect the results
names(results)
head(results$guilds$table)
results$exotic$table
results$endemic$table
results$rarity$table
## End(Not run)
Classify Ant Communities Across Multiple Sites
Description
Applies the AntClassify pipeline to each site (row) of a community matrix and returns aggregated guild abundance and richness matrices.
Usage
antclassify_community(
comm,
guild_col = "antclassify_guild",
ask = FALSE,
validate = FALSE,
delay = 0.5,
...
)
Arguments
comm |
A community matrix with sites as rows and species as columns. Species names must match the nomenclature used in the internal databases. |
guild_col |
Character string giving the name of the guild column to use
for aggregation. Must be one of |
ask |
Logical; if TRUE, prompts for interactive resolution of ambiguous guild classifications for each site. Default is FALSE for non-interactive multi-site workflows (recommended for reproducibility). |
validate |
Logical; if TRUE, validates species names via GBIF ONCE before processing sites. Default is FALSE for reproducibility. |
delay |
Numeric; seconds between GBIF API calls when validate = TRUE. |
... |
Additional arguments passed to |
Value
A list with three components:
by_site |
A list of length equal to |
guild_abundance |
A matrix of guild abundances (sites × guilds). |
guild_richness |
A numeric vector of length |
Examples
# Small community matrix with two sites and six species
comm <- matrix(c(5, 0, 2, 0, 1, 3,
2, 4, 0, 2, 0, 0),
nrow = 2, byrow = TRUE,
dimnames = list(c("Site1", "Site2"),
c("Atta sexdens", "Camponotus atriceps",
"Pheidole megacephala", "Wasmannia auropunctata",
"Solenopsis saevissima", "Nylanderia fulva")))
# Run the classification (validate = FALSE to avoid GBIF calls in examples)
results <- antclassify_community(comm, guild_col = "antclassify_guild",
validate = FALSE)
results$guild_abundance
results$guild_richness
Assign Functional Guilds for Ants
Description
Classifies ants into functional guilds using four different ecological databases.
Usage
assign_guild_ants(
comm,
verbose = TRUE,
plot = TRUE,
validate = TRUE,
delay = 0.5,
ask = TRUE,
preferred_guilds = NULL
)
Arguments
comm |
A community matrix where species are columns and samples are rows. |
verbose |
Logical; if TRUE, displays progress messages. |
plot |
Logical; if TRUE, displays guild proportion plots. |
validate |
Logical; if TRUE, validates species names using GBIF before analysis. |
delay |
Numeric; seconds to wait between GBIF API calls when validate = TRUE. |
ask |
Logical; if TRUE (default), prompts for interactive resolution of ambiguous classifications. Set to FALSE for non-interactive use (reproducible scripts, testing, vignettes). |
preferred_guilds |
Optional named list to specify preferred guilds for genera with multiple options (e.g., |
Value
Invisibly returns a list with two elements:
table |
A data frame with species, abundance, percentage, guild assignments from each system, and |
plots |
A list of four ggplot2 objects, one for each guild classification system. |
Identify Endemic Ant Species (Atlantic Forest)
Description
Checks a community matrix for ant species endemic to the Brazilian Atlantic Forest based on Silva et al. (2025).
Usage
check_endemic_atlantic_ants(
comm,
verbose = TRUE,
plot = TRUE,
plot_type = c("status", "species"),
validate = TRUE,
delay = 0.5
)
Arguments
comm |
A community matrix where species are columns and samples are rows. |
verbose |
Logical; if |
plot |
Logical; if |
plot_type |
Character; type of plot to display. |
validate |
Logical; if |
delay |
Numeric; seconds to wait between GBIF API calls when |
Value
Invisibly returns a list with two elements:
table |
A data frame containing endemic species detected, with columns species, abundance, and percentage. |
plot |
A ggplot2 object. |
Identify Exotic Ant Species (Brazil)
Description
Checks a community matrix for known exotic ant species in Brazil. The list is compiled from Wong et al. (2023) and Vieira (2025) and stored in exotic_db.
Usage
check_exotic_ants(
comm,
verbose = TRUE,
plot = TRUE,
plot_type = c("status", "species"),
validate = TRUE,
delay = 0.5
)
Arguments
comm |
A community matrix where species are columns and samples are rows. |
verbose |
Logical; if |
plot |
Logical; if |
plot_type |
Character; type of plot to display. |
validate |
Logical; if |
delay |
Numeric; seconds to wait between GBIF API calls when |
Value
Invisibly returns a list with two elements:
table |
A data frame with exotic species detected. Columns: |
plot |
A ggplot2 object. |
Identify Ant Rarity Forms (Atlantic Forest)
Description
Checks a community matrix for ant rarity forms in the Brazilian Atlantic Forest based on Silva et al. (2024).
Usage
check_rarity_atlantic_ants(
comm,
verbose = TRUE,
plot = TRUE,
plot_type = c("status", "species"),
validate = TRUE,
delay = 0.5
)
Arguments
comm |
A community matrix where species are columns and samples are rows. |
verbose |
Logical; if |
plot |
Logical; if |
plot_type |
Character; type of plot to display. |
validate |
Logical; if |
delay |
Numeric; seconds to wait between GBIF API calls when |
Value
Invisibly returns a list with two elements:
table |
A data frame containing rare species detected, with columns species, rarity_form, abundance, and percentage. |
plot |
A ggplot2 object. |
Internal datasets used by AntClassify
Description
The datasets distributed with AntClassify include functional guild, rarity, exotic status and endemic status resources. Their classifications represent independent systems.
Usage
delabie_db
endemic_db
generic_db
rarity_db
silva_db
silvestre_db
Format
- delabie_db
27 rows and 2 columns: target and guild.
- endemic_db
49 rows and 2 columns: species and status.
- generic_db
48 rows and 5 columns: target, guild, guild_status, guild_notes, and foraging_strategy.
- rarity_db
120 rows and 3 columns: species, assessed, and rarity_form.
- silva_db
58 rows and 2 columns: target and guild.
- silvestre_db
66 rows and 2 columns: target and guild.
An object of class data.frame with 49 rows and 2 columns.
An object of class data.frame with 48 rows and 5 columns.
An object of class data.frame with 120 rows and 3 columns.
An object of class data.frame with 58 rows and 2 columns.
An object of class data.frame with 66 rows and 2 columns.
Details
The generic_db database contains the primary AntClassify guild assignment and associated metadata. DataDeficient taxa have NA in guild and are excluded from guild-proportion plots.
Exotic ant species recorded in Brazil
Description
A curated list of exotic ant species recorded in Brazil, compiled from Wong et al. (2023) and Vieira (2025).
Usage
exotic_db
Format
A data frame with 25 rows and 3 columns:
- species
Character. Species name.
- source
Character. Source reference(s): "Wong et al. 2023", "Vieira 2025", or both.
- native_in_some_brazil_regions
Logical. TRUE if the species is native in some Brazilian regions and exotic in others (e.g., Wasmannia auropunctata, Nylanderia fulva).
Details
The database is versioned (attr(exotic_db, "version")). Current version: 2.0.0.
Source
doi:10.6084/m9.figshare.21666191
References
Wong, M. K. L., Guenard, B., & Economo, E. P. (2023). The global spread and invasion capacities of alien ants. Current Biology, 33(3), 566-571.
Vieira, V. B. (2025). Quem sao e onde estao as formigas exoticas do Brasil? Master's thesis, Universidade Federal do Parana, Curitiba, Brazil.
Validate Species Names Using GBIF API
Description
Checks species names against the GBIF taxonomic backbone. If an exact match is found, the accepted name (or canonical name) is used. If no exact match is found, the original name is kept and a warning is issued.
Usage
validate_species_names(
comm,
verbose = TRUE,
delay = 0.5,
return_changes = FALSE,
use_cache = TRUE
)
Arguments
comm |
A community matrix (rows = sites, columns = species). |
verbose |
Logical; if TRUE, displays progress messages. |
delay |
Numeric; seconds to wait between API calls (default 0.5). |
return_changes |
Logical; if TRUE, returns a list with components
|
use_cache |
Logical; if TRUE (default), caches GBIF responses locally and reuses them across calls. Disable to force a fresh API call. |
Details
Results are cached locally to ensure reproducibility across runs
(use_cache = TRUE, default). The cache is stored in the
user-specific directory returned by tools::R_user_dir("AntClassify", "cache").
Value
If return_changes = FALSE (default), a community matrix with
updated column names. The changes table is attached as attribute
gbif_changes and the access date as gbif_access_date.
gbif_backbone_version (recorded via rgbif::gbif_citation()) and the rgbif package version as rgbif_version. These metadata allow the taxonomy version to be checked for reproducibility.
If return_changes = TRUE, a list with components comm and
changes. The changes data frame has columns: original_name,
matched_name, matchType, usageKey, from_cache
(logical), and changed (logical).
Examples
## Not run:
data(ant_community)
# Return matrix only (default)
comm_validated <- validate_species_names(ant_community)
# Retrieve the changes table
changes <- attr(comm_validated, "gbif_changes")
# Or return both at once
out <- validate_species_names(ant_community, return_changes = TRUE)
out$comm
out$changes
## End(Not run)