Declining growth-related work contributes to hypometric metabolic scaling during ant colony ontogeny
Abstract
Analysis code for ant colony metabolism and task allocation Associated manuscript Declining growth-related work contributes to hypometric metabolic scaling during ant colony ontogeny Colin M. Lynch, Theodore P. Pavlic, Xiaohui Guo, Gailan Khanania, Cole Busby, Emma Siebrandt, Jennifer H. Fewell, and Jon F. Harrison. Correspondence: Colin M. Lynch, cmlynch2@asu.edu. The analyses combine whole-colony metabolism and behavioral observations from ten Pogonomyrmex californicus colonies measured at two developmental stages with task-associated metabolic measurements from individual workers in functioning colonies. The colony dataset contains 20 paired colony-stage observations. Reproduction status This README describes the three supplied R scripts and their relationship to the accompanying main manuscript and SI Appendix. The scripts implement the principal statistical analyses. Files needed Place the scripts and input CSV files together in one directory. File Purpose Used by colonyScaling.R Colony metabolic scaling and model comparison Colony scaling workerBehavior.R Worker behavior, velocity, task allocation, and division of labor Worker behavior taskMetabolismAndPrediction.R Task metabolism and colony predictions Task metabolism and prediction colonyData.csv Colony identity, developmental session, total mass, worker number, brood mass, colony MR, and stored division-of-labor indices All scripts RawDataFinal.csv Scored worker tasks, locations, and positional observations Worker behavior; task metabolism and prediction CarbonDioxideofTasksBIOR.csv Background-corrected focal-worker CO2 measurements, task codes, and source-colony IDs Task metabolism and prediction 4PeriodCO2Trace.csv Representative focal-worker CO2 time series Optional section of task metabolism and prediction The three scripts alone are insufficient to reproduce the results. The required input CSV files must be included in the archive or made available to reviewers through a documented access route. Software Use R with support for the native pipe operator (|>; R 4.1.0 or later). RStudio is recommended for viewing plots. The scripts use: packages <- c( "ggplot2", "dplyr", "tidyr", "patchwork", "lmerTest", "segmented", "emmeans", "pbkrtest", "compositions", "dunn.test", "multcompView" ) install.packages(packages, repos = "https://cloud.r-project.org") Each script also checks for missing packages and attempts to install them from CRAN. Internet access and permission to write to an R package library are therefore needed if packages are missing. Dependencies include lme4, which is called explicitly by the scripts. Run the analyses 1. Set the data directory Each script starts by clearing the workspace and setting the working directory: rm(list = ls(all.names = TRUE), envir = .GlobalEnv) setwd("C:/Users/your_name/Documents/Metabolism_Analysis") Replace your_name with your Windows username, or edit this path in all three scripts to point to your local copy. Keep the exact CSV filenames shown above. Save any workspace objects you need before running a script, because each run clears the global workspace. Changing the working directory in the console alone is insufficient because each script resets it when sourced. 2. Run in RStudio Open the scripts from the data directory and run them in this order: source("colonyScaling.R") source("workerBehavior.R") source("taskMetabolismAndPrediction.R") If the console is not already in the directory containing the scripts, source them using their full paths. Each script then switches to its configured data directory. The analyses are self-contained and do not require objects from a previous script. Running them in order follows the paper. Numerical results and session information print to the console; no text reports are written. Main figures print to the RStudio plot pane during interactive execution. Use the plot history to move between figures and the Export button to save a displayed plot. The scripts do not automatically save figure files. Map from analyses to the paper Paper item Script and output Figure 3; SI Appendix A.4; Table S7 colonyScaling.R: separate-stage OLS fits, pooled linear model, centered quadratic model, continuous segmented model initialized at median log mass, and colony random-intercept model fitted by maximum likelihood Figure 4A; SI Appendix A.7; Table S2 workerBehavior.R: nine-task model, mature-minus-juvenile estimated marginal mean contrasts, and Holm adjustment across nine contrasts Figure 4B; Table S3 workerBehavior.R: separately fitted four-class model and Holm adjustment across four contrasts Figure 4C; SI Appendix A.6–A.7 workerBehavior.R: worker velocity model and within-stage velocity regressions Division of labor; SI Appendix A.4, A.6–A.7 workerBehavior.R: reconstructed task–worker index, paired stage comparison, and within-stage regressions Figure S1; SI Appendix A.6 workerBehavior.R: four-class proportions versus log worker number; nine-task ILR regressions are printed separately Figure 5; SI Appendix B.3; Table S4 taskMetabolismAndPrediction.R: calculated task MR, descriptive statistics, Kruskal–Wallis test, nominal two-sided Dunn tests, supporting mixed model, and variance tests Figure 6; SI Appendix A.9; Table S5 taskMetabolismAndPrediction.R: measured and predicted colony mass-specific MR, paired tests, pooled correlations, stage-adjusted associations, median sensitivity calculation, and paired bootstrap SI Appendix A.8; Table S6 taskMetabolismAndPrediction.R: resting-reference colony regression, complete-task predictions, normal-Wald intervals, and contrasts Figure S4; SI Appendix B.4 taskMetabolismAndPrediction.R: optional representative CO2 trace and signal-to-noise calculation