scieee AI-readable full text Open interactive document viewer

commecometrics: an R package for trait-environment modelling at the community level

Hurtado-Materon, María A.; Siciliano-Martina, Leila; Short, Rachel A.; McGuire, Jenny L.; Lawing, A. Michelle

Abstract

The R package commecometrics provides an accessible, open-access framework for modelling trait–environment relationships using community-level trait data from modern and ancient species. Ecometrics links the trait distributions of communities to their local environmental variables, enabling the reconstruction of past conditions and the prediction of community responses under future climate change. Existing tools for functional trait analysis often lack palaeontological integration or are limited to specific taxa. commecometrics addresses these gaps by offering a suite of functions to summarise trait distributions, construct ecometric models, visualise trait–environment relationships, assess model robustness and reconstruct environmental conditions. The package is designed for broad applicability across ecological and palaeoecological studies and includes tools for trait-based biodiversity analysis beyond ecometrics. Through a worked example using carnassial tooth relative blade length (RBL) in carnivoran mammals, we demonstrate the package's capabilities for analysing trait–environment dynamics across space and time.

Full text

Biodiversity Data Journal 13: e168221 doi: 10.3897/BDJ.13.e168221 R Package commecometrics: an R package for traitenvironment modelling at the community level María A. Hurtado-Materon , Leila Siciliano-Martina , Rachel A. Short , Jenny L. McGuire , A. Michelle Lawing ‡ Ecology and Evolutionary Biology Program, Texas A&M University. Department of Ecology and Conservation Biology, Texas A&M University, College Station, United States of America § Department of Biology, Texas State University, San Marcos, United States of America | Department of Natural Resource Management, South Dakota State University, Rapid City, United States of America ¶ School of Biological Sciences, Georgia Institute of Technology. School of Earth and Atmospheric Sciences, Georgia Institute of Technology. Interdisciplinary Graduate Program in Quantitative Biosciences., Atlanta, United States of America # Department of Ecology and Conservation Biology, Texas A&M University. Ecology and Evolutionary Biology Program, Texas A&M University, College Station, United States of America Corresponding author: María A. Hurtado-Materon ([email protected]) Academic editor: Zachary Foster Received: 08 Aug 2025 | Accepted: 17 Sep 2025 | Published: 16 Oct 2025 Citation: Hurtado-Materon MA, Siciliano-Martina L, Short RA, McGuire JL, Lawing AM (2025) commecometrics: an R package for trait-environment modelling at the community level. Biodiversity Data Journal 13: e168221. https://doi.org/10.3897/BDJ.13.e168221 Abstract The R package commecometrics provides an accessible, open-access framework for modelling trait–environment relationships using community-level trait data from modern and ancient species. Ecometrics links the trait distributions of communities to their local environmental variables, enabling the reconstruction of past conditions and the prediction of community responses under future climate change. Existing tools for functional trait analysis often lack palaeontological integration or are limited to specific taxa. commecometrics addresses these gaps by offering a suite of functions to summarise trait distributions, construct ecometric models, visualise trait–environment relationships, assess model robustness and reconstruct environmental conditions. The package is designed for broad applicability across ecological and palaeoecological studies and includes tools for trait-based biodiversity analysis beyond ecometrics. Through a worked example using carnassial tooth relative blade length (RBL) in ‡ § | ¶ # © Hurtado-Materon M et al. This is an open access article distributed under the terms of the Creative Commons Attribution License (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. carnivoran mammals, we demonstrate the package’s capabilities for analysing trait– environment dynamics across space and time. Keywords ecometrics, palaeoecology, community ecology, functional traits. Introduction Ecometrics is the trait-based quantitative study of the relationship between communitylevel trait distributions and environmental variables (Polly et al. 2011). The central premise is that certain trait values are more likely to occur in specific environmental settings, allowing the use of community traits to infer local conditions (Polly et al. 2016). Summarising trait data at the community level (e.g. mean, standard deviation) and comparing these summaries with known environmental variables allows ecometric models to infer environmental conditions at fossil sites or predict future trait distributions under climate change (McGuire et al. 2023). Reconstructing ancient environments is challenging due to the incompleteness of the fossil record, preservation biases and the complexity of geochemical interpretation (Koch 1998, Jackson and Erwin 2006). The latter requires understanding of the chemical processes involved in fossil formation and results are influenced by factors such as diet, physiology and water sources (Koch 1998, Jackson and Erwin 2006). Given the fragmentary and complex nature of the fossil record, multiple lines of evidence and methodological approaches are often necessary to gain a full picture of ancient environments (Jackson and Erwin 2006). Ecometrics offers an alternative framework for reconstructing past environments from fossil remains of ancient communities (Polly and Head 2015). Ecometric models have been applied in mammals (Polly 2010, Short and Lawing 2021, Schap et al. 2024), plants (Dunn et al. 2015, Peppe et al. 2017) and reptiles (Head et al. 2009, Lawing et al. 2012, Parker et al. 2023) to understand the relationship between functional traits and environmental variables such as precipitation, temperature and vegetation cover. Ecometric analyses have consistently demonstrated strong links between communitylevel trait distributions and environmental variables. For instance, hypsodonty (an index of tooth crown height to root depth) in mammals reflects annual precipitation experienced by communities of large herbivores (Janis 1988, Fortelius et al. 2002, Eronen et al. 2010). Species in open, arid habitats with grass tend to have higher hypsodonty indices, while those in forested, less abrasive environments have lower values (Eronen et al. 2010). Studies that applied ecometrics to megafaunal communities, revealed that trait compositions reconfigured to align with environmental conditions that underlie massive biodiversity turnover events (Lauer et al. 2023). Other applications have explored the predictive power of functional traits – body size in turtles (Parker et al. 2023), snakes (Lawing et al. 2012) and herbivorous mammals (Lauer et al. 2023, Wilson et al. 2024), 2Hurtado-Materon M et al diet in herbivorous (Short et al. 2021, Wilson et al. 2024), carnivorous (Siciliano‐Martina et al. 2024) and small mammals (Schap et al. 2024) and locomotion traits in carnivores (Polly 2010) and artiodactyls (Short and Lawing 2021, Short et al. 2023) – demonstrating that ecometric models can capture environmental patterns at regional and continental scales and can provide informative palaeoclimate reconstructions. These results highlight the value of ecometrics as a functional, comparative tool to model biotic responses to changes in climate and to infer past environmental conditions. Despite their utility, ecometrics methods have been limited by the absence of an accessible, standardised computational platform. R packages for analysing functional traits have been developed in recent years. Current packages focus on trait manipulation, the estimation of functional spaces based on traits (Carmona et al. 2024) and the access to and exploration of databases containing functional traits and environmental variables (Denelle et al. 2023, Lam et al. 2024). Some also summarise functional trait distributions at the community level (Pavoine 2020, Zhang et al. 2021, Magneville et al. 2022, Grenié and Gruson 2023) and enable the analysis of ecological data from a metacommunity perspective (Debastiani and Pillar 2012). However, these packages are primarily focused on plants, lack easy integration with geographic space and do not include functions to reconstruct palaeoenvironments based on the fossil record. To address these gaps, we introduce commecometrics, an R package that facilitates the integration of trait data with environmental predictors across temporal and spatial scales. It offers a workflow for summarising community trait metrics, building ecometric models and evaluating trait–environment relationships with visualisation tools. In this paper, we describe the structure and functionality of commecometrics, demonstrate its use with an empirical dataset and discuss potential applications in conservation and palaeoecology. commecometrics is intended for ecologists, palaeontologists and conservation biologists interested in using trait-based methods to explore how traits within communities reflect their environments in the past or present. The commecometrics package is modular, allowing users to apply individual components of the workflow independently, such as summarising traits, testing models, or reconstructing past climates, depending on the structure of their data and research goals. Installation The commecometrics package is available on CRAN and can be installed using the standard install.packages() function. The development version is hosted on GitHub. # Install the stable version from CRAN install.packages("commecometrics") # Install the development version from GitHub # First install devtools if not already installed commecometrics: an R package for trait-environment modelling at the community ... 3 install.packages("devtools") devtools::install_github("mariahm1995/commecometrics") Usage The commecometrics package provides a modular workflow for analysing trait– environment relationships at the community level and reconstructing past environments using fossil trait data. Fig. 1 outlines the main components of the workflow. Figure 1. Workflow of the commecometrics R package. The package implements a modular pipeline to model and reconstruct trait–environment relationships. Green boxes represent user-provided inputs, including modern and fossil species-level trait data, species distributions and environmental sampling points. Red boxes indicate outputs generated by package functions. Dashed lines represent optional steps. Community-level trait summaries (e.g. mean, standard deviation) are calculated using summarize_traits_by_point() and can be modelled against environmental variables using ecometric_model() or ecometric_model_qual() for continuous or categorical traits, respectively. Model performance can be assessed with sensitivity analyses and trait–environment patterns can be visualised using ecometric space plots. Finally, ecometric models can be applied to fossil trait data to reconstruct past environmental conditions.  4Hurtado-Materon M et al The process begins with three core inputs: (1) a dataset with species-level trait values; (2) a set of species distribution maps in shapefile format and (3) a set of geographic sampling points with associated environmental variables. These inputs are combined using the summarize_traits_by_point() function, which calculates community-level trait distributions (e.g. mean and standard deviation) at each geographic point based on the species present. These summarised trait data form the basis for all downstream analyses, but may be a desired output in itself. After the first step, users can: (1) Build an ecometric model using ecometric_model() or ecometric_model_qual() (for categorical traits). These models describe how trait distributions relate to environmental variables across the landscape; (2) Evaluate model performance using sensitivity_analysis() or sensitivity_analysis_qual() to test robustness and assess how well the model captures the underlying trait–environment relationships; (3) Visualise the ecometric space using ecometric_space() or ecometric_space_qual(), which plots environmental estimates across trait value bins, providing an intuitive map of how traits vary with environment and (4) Reconstruct environmental conditions at fossil sites using reconstruct_env() or reconstruct_env_qual(). These functions estimate past environmental conditions based on the trait composition of fossil communities. commecometrics provides a flexible and modular framework for conducting ecometric analyses. While outputs from one function (e.g. community-level trait summaries) can be passed to subsequent functions (e.g. model fitting), users are not required to follow a rigid pipeline. For instance, the arguments comm_metric_1 and comm_metric_2 in the summarize_traits_by_point() function allow users to apply any summary function to community trait data. However, users may supply a custom dataframe, such as one containing community-weighted trait means based on energy intake and use it directly in downstream modelling functions (Žliobaitė and Lawing 2025). This flexible design supports a wide range of applications. Usage Beyond Ecometric Analysis The R package commecometrics supports a wide range of community-level analyses beyond ecometric applications (see Table 1 for function descriptions). It allows users to compile species lists for specific geographic locations, calculate trait-based metrics and assign communities to continents based on spatial coordinates. These capabilities are broadly applicable to studies examining various dimensions of biodiversity. In particular, the function summarize_traits_by_point() can be employed in diverse analytical contexts beyond traditional ecometric modelling. Trait distributions are calculated for each community using a user-specified function. By default, the mean and standard deviation are computed, as these are commonly used in ecometric analyses. However, users can substitute any function that accepts a numeric vector as input, including the fd_ functions from the R package fundiversity (see example below), to derive other functional diversity metrics (Grenié and Gruson 2023). commecometrics: an R package for trait-environment modelling at the community ... 5 Function name Description Functions for general community analysis summarize_traits_by_point() Provides two trait-based metrics for each geographic point. inspect_point_species() Creates an interactive map to verify species overlap and information related to selected points. optimal_bins() Calculates the optimal number of bins for a numeric vector based on Scott's rule. Functions exclusive to ecometric analysis ecometric_model() and ecometric_model_qual() Builds an ecometric trait space for quantitative and qualitative environmental variables. ecometric_space() and ecometric_space_qual() Visualises the ecometric space. reconstruct_env() and reconstruct_env_qual() Uses fossil community trait summaries to reconstruct past environmental conditions. sensitivity_analysis() and sensitivity_analysis_qual() Evaluates the performance of ecometric models. traitsByPoint <- summarize_traits_by_point( points_df = geoPoints, trait_df = traits, species_polygons = spRanges, summary_trait_1 = function(x) fundiversity::fd_fdis(x), trait_column = "RBL", species_name_col = "sci_name", continent = TRUE, parallel = TRUE) The function inspect_point_species() allows users to verify the species present at each geographic point and review associated metrics. It supports data exploration by providing a visual, interactive interface for examining large datasets. Using the leaflet package Table 1. Functions included in the R package commecometrics, with brief descriptions of their purpose. For more detailed information, consult the package manual or use the help documentation for individual functions. 6Hurtado-Materon M et al (Cheng et al. 2015), the function generates an interactive map that displays selected sampling points as coloured markers: blue for points with enough species that have trait data (above a user-defined threshold) and red for those that fall below. Clicking on any point opens a pop-up showing the point ID, trait summary statistics (mean, standard deviation, richness), optional environmental variable values and a list of overlapping species (Fig. 2). This tool facilitates interpretability by linking spatial locations to ecological and trait-based summaries in an intuitive format, making it broadly applicable to ecological and biogeographic research. Example To demonstrate the functionality of commecometrics, we applied the package to a dataset of carnivoran carnassial tooth relative blade length (RBL) to test its relationship with the habitat structure (Siciliano‐Martina et al. 2024). This example illustrates the complete Figure 2. Interactive map output from the inspect_point_species() function, displaying species composition and associated metrics for each sampling point. Pop-up windows provide information per point, including species identity, summary trait metrics, species richness, richness based on trait availability and the value of an environmental variable. Point status is colour-coded: blue indicates valid points (≥ 3 species) and red indicates non-valid points (< 3 species) based on the species richness threshold.  commecometrics: an R package for trait-environment modelling at the community ... 7 workflow: summarising trait data, fitting a categorical ecometric model, projecting fossil sites, visualising ecometric space and evaluating model performance. Step 1: Load and prepare data This example uses three input datasets provided by the user. The file sampling_points.csv contains environmental sampling locations and includes a column named "VegSimple", which classifies each point into a categorical vegetation type. The file traits.csv provides species-level values for the carnassial tooth relative blade length. Finally, species distribution data are provided in a shapefile containing geographic range polygons for all terrestrial mammals. In this analysis, the dataset is filtered to include only species belonging to the order Carnivora. The polygons were downloaded from the IUCN Red List website, which hosts expert-reviewed range maps for many taxonomic groups (IUCN 2025). Any taxonomic group with available distribution data on the IUCN platform can be used with the commecometrics package. # Download data from Figshare options(timeout = 600) download.file("https://ndownloader.figshare.com/files/56228033", destfile = "data.zip", mode = "wb") unzip("data.zip") # Load data points <- read.csv("data/sampling_points.csv") traits <- read.csv("data/traits.csv") fossil <- read.csv("data/fossil_RBL.csv", header = TRUE) geometry <- sf::st_read("data/data_0.shp") geography$SCI_NAME <- gsub(" ", "_", geography$SCI_NAME) Step 2: Summarise traits at sampling points The first step is to calculate community-level trait summaries at each environmental sampling point. This is done by intersecting each point with the species range polygons to determine which species are present and then computing the mean and standard deviation of the selected trait across those species. This summarised trait information forms the basis for all downstream ecometric modelling steps. traitsByPoint <- summarize_traits_by_point( points_df = points, trait_df = traits, 8Hurtado-Materon M et al species_polygons = geometry, species_name_col = "SCI_NAME", trait_column = "RBL") To explore the species composition at sampling points, users can interact with the inspect_point_species() function, described in the Usage Beyond Ecometric Analysis section. If point_ids argument is left NULL, the function selects a random sample of 10 points. Otherwise, users can inspect specific point IDs to examine known or targeted locations. The user can also select the number of points to inspect via the argument n_random. # View species present at randomly selected points with at least 3 species with trait data inspect_point_species( traits_summary = traitsByPoint, min_species_valid = 3) # View species at specific point IDs inspect_point_species( traits_summary = traitsByPoint, min_species_valid = 3, point_ids = c("113435", "99936", "101328"), ID_col = "GlobalID") Step 3: Build a categorical ecometric model With community-level trait summaries available, the next step is to build an ecometric model that relates trait distributions to a categorical environmental variable. In this case, we use "VegSimple", a simplified vegetation classification. The model bins the trait space (mean and standard deviation of RBL) into a grid and assigns each bin to the most likely vegetation category based on the observed data. Predicted environmental variables are calculated using Maximum Likelihood; this method has been shown to produce the most accurate estimates from community trait values (Short et al. 2021). modelVeg <- ecometric_model_qual( points_df = traitsByPoint$points, category_col = "VegSimple", grid_bins_1 = 25, commecometrics: an R package for trait-environment modelling at the community ... 9 • Lawing AM, Head J, Polly P (2012) The ecology of morphology: The ecometrics of locomotion and macroenvironment in North American snakes. In: Louys J (Ed.) Paleontology in Ecology and Conservation. [ISBN 978-3-642-25037-8]. https://doi.org/ 10.1007/978-3-642-25038-5_7 • Magneville C, Loiseau N, Albouy C, Casajus N, Claverie T, Escalas A, Leprieur F, Maire E, Mouillot D, Villéger S (2022) mFD: an R package to compute and illustrate the multiple facets of functional diversity. Ecography 2022 (1). https://doi.org/10.1111/ecog.05904 • McGuire J, Lawing AM, Díaz S, Stenseth N (2023) The past as a lens for biodiversity conservation on a dynamically changing planet. Proceedings of the National Academy of Sciences 120 (7). https://doi.org/10.1073/pnas.2201950120 • Parker A, Müller J, Boisserie J, Head J (2023) The utility of body size as a functional trait to link the past and present in a diverse reptile clade. Proceedings of the National Academy of Sciences 120 (7). https://doi.org/10.1073/pnas.2201948119 • Pavoine S (2020) adiv: An r package to analyse biodiversity in ecology. Methods in Ecology and Evolution 11 (9): 1106‑1112. https://doi.org/10.1111/2041-210X.13430 • Pedersen TL (2019) patchwork: The composer of plots. Institution: Comprehensive R Archive Network Pages: 1.3.0. https://doi.org/10.32614/CRAN.package.patchwork • Peppe D, Baumgartner A, Flynn A, Blonder B (2017) Reconstructing paleoclimate and paleoecology using fossil leaves. https://doi.org/10.31233/osf.io/stzuc • Polly, Eronen J, Fred M, Dietl G, Mosbrugger V, Scheidegger C, Frank D, Damuth J, Stenseth N, Fortelius M (2011) History matters: ecometrics and integrative climate change biology. Proceedings of the Royal Society B: Biological Sciences https://doi.org/ 10.1098/rspb.2010.2233 • Polly, Lawing AM, Eronen J, Schnitzler J (2016) Processes of ecometric patterning: modelling functional traits, environments, and clade dynamics in deep time. Biological Journal of the Linnean Society 118 (1): 39‑63. https://doi.org/10.1111/bij.12716 • Polly PD (2010) Tiptoeing through the trophics: geographic variation in carnivoran locomotor ecomorphology in relation to environment. In: Goswami A, Friscia A (Eds) Carnivoran Evolution. Cambridge University Press [ISBN 978-0-521-51529-0 978-0-521-73586-5 978-1-139-19343-6]. https://doi.org/10.1017/CBO9781139193436.014 • Polly PD, Head J (2015) Measuring earth-life transitions: Ecometric analysis of functional traits from Late Cenozoic Vertebrates. The Paleontological Society Papers 21: 21‑46. https://doi.org/10.1017/S1089332600002953 • Schap J, McGuire J, Lawing AM, Manthi F, Short R (2024) Ecometric models of small mammal hypsodonty can estimate paleoprecipitation across eastern Africa. Palaeogeography, Palaeoclimatology, Palaeoecology 643 https://doi.org/10.1016/j.palaeo. 2024.112181 • Scott D (1979) On optimal and data-based histograms. Biometrika 66 (3): 605‑610. https:// doi.org/10.1093/biomet/66.3.605 • Short R, Lawing AM (2021) Geography of artiodactyl locomotor morphology as an environmental predictor. Diversity and Distributions 27 (9): 1818‑1831. https://doi.org/ 10.1111/ddi.13371 • Short R, Pinson K, Lawing AM (2021) Comparison of environmental inference approaches for ecometric analyses: Using hypsodonty to estimate precipitation. Ecology and Evolution 11 (1): 587‑598. https://doi.org/10.1002/ece3.7081 • Short R, McGuire J, Polly PD, Lawing AM (2023) Trophically integrated ecometric models as tools for demonstrating spatial and temporal functional changes in mammal 16 Hurtado-Materon M et al communities. Proceedings of the National Academy of Sciences 120 (7). https://doi.org/ 10.1073/pnas.2201947120 • Siciliano‐Martina L, McGuire J, Hurtado‐Materon M, Short R, Lauer D, Schap J, Müller J, Manthi F, Head J, Lawing AM (2024) Ecometrics demonstrates that the functional dental traits of carnivoran communities are filtered by climate. Ecology and Evolution 14 (10). https://doi.org/10.1002/ece3.70214 • Vermillion WA, Polly PD, Head J, Eronen J, Lawing AM (2018) Ecometrics: A trait-based approach to paleoclimate and paleoenvironmental reconstruction. In: Croft D, Su D, Simpson S (Eds) Methods in Paleoecology: Reconstructing Cenozoic Terrestrial Environments and Ecological Communities. Springer Cham [ISBN 978-3-319-94264-3]. https://doi.org/10.1007/978-3-319-94265-0_17 • Wickham H, Chang W, Henry L, Pedersen TL, Takahashi K, Wilke C, Woo K, Yutani H, Dunnington D, Van Den Brand T (2007) ggplot2: Create elegant data visualisations using the grammar of graphics. Institution: Comprehensive R Archive Network Pages: 3.5.2. https://doi.org/10.32614/CRAN.package.ggplot2 • Wilson O, Sánchez R, Chávez-Aponte E, Carrillo-Briceño J, Saarinen J (2024) Application of herbivore ecometrics to reconstruct Neogene terrestrial palaeoenvironments in Falcón, Venezuela. Palaeogeography, Palaeoclimatology, Palaeoecology 651 https://doi.org/10.1016/j.palaeo.2024.112397 • Zhang T, Russell M, Domke G (2021) FEEr: An R package for calculating functional extension and evenness index. Ecological Indicators 133 https://doi.org/10.1016/j.ecolind. 2021.108365 • Žliobaitė I, Lawing AM (2025) Trait-based approaches to paleoenvironmental reconstructions: What is in the community-weighted trait mean? Palaeogeography, Palaeoclimatology, Palaeoecology 672 https://doi.org/10.1016/j.palaeo.2025.112982 commecometrics: an R package for trait-environment modelling at the community ... 17