DOI: 10.5061/dryad.ffbg79d4g
title: Code and simulated data from: Overexploitation can counteract top-down control and the paradox of enrichment in simple food chains

description: Because of its high abundance or its high feeding intensity, a consumer
 can overexploit its resource by consuming it on a shorter timescale than
 resource regeneration. While this short-term overexploitation is
 widespread in nature, its general implications for biotic control patterns
 and ecosystem stability are not clear. Here we use a
 resource-plant-herbivore food chain model allowing for short-term
 overexploitation (i.e., the plant can overexploit the resource and/or the
 herbivore can overexploit the plant). We uncover the conditions under
 which either type of overexploitation occurs and show that they
 qualitatively change ecological patterns, mainly by suppressing top-down
 control when interaction strength is high. When plant productivity
 increases, top-down control patterns are suppressed above the level at
 which plants start to overexploit resources. Similarly, when herbivory
 intensity increases, top-down control patterns disappear when plants
 become overexploited. Overexploitation also prevents enrichment-driven
 destabilization by capping the energy fluxes in the ecosystem. These
 findings connect top-down and bottom-up controls in a single framework,
 and highlight the role overexploitation can play in structuring and
 stabilizing food chains via the modulation of interaction strengths.
description: Archive includes code necessary to reproduce the
 manuscript's analyses, as well as generated data and output.
 Simulations are run using the Julia programming language and visualized
 with R.
description: # Resource-Plant-Herbivore ## Archived content in
 Resource-Plant-Herbivore.zip * `./data` contains simulated data (see
 details below) * `./output` contains notebooks with figures and supporting
 information * this directory wraps environments to manage R and Julia
 installations * `notebooks/report_figures.Rmd` contains R code to generate
 figures from data files * `notebooks/supplement.qmd` is used to build the
 Supporting information pdf. This includes analytical results computed in a
 Julia notebook. * `packages/LocalRPHModel.jl` contains the Julia code for
 simulations * we provide a `Dockerfile` for easier management of software
 dependencies ### `data` directory The content of this subdirectory can be
 re-generated by running the Julia scripts `scripts/generate_data_local.jl`
 and `scripts/generate_data_si.jl` (see below for installation steps). As
 in Methods and Table 1 in the main manuscript, `a` denotes herbivory
 intensity, `r` denotes plant productivity and `nu` denotes recycling
 efficiency. Data files for the main manuscript figures include: *
 `numerical_stabilities.csv`: output of the numerical evaluation of the
 jacobian matrix around each fixed point for every parameter combination.
 comma-separated values with `equilibrium` (fixed point name as in Fig. 2
 and equations S1 to S7), `a`, `r`, `nu`, `stab` (boolean: is the attractor
 stable), `attractor` (string: attractor type). `stab` and `attractor` are
 set to "fail" when the (system, parameters) combination yields
 negative biomass values * `eq_validities.csv`: *validity* of each fixed
 point for each parameter combination, i.e. are the biomass values at each
 equilibrium meeting the overexploitation conditions for the corresponding
 system. comma-separated values with `equilibrium` (fixed point name as in
 Fig. 2 and equations S1 to S7), `a`, `r`, `nu` and `valid` (boolean: is
 the fixed point valid) * `transects1.csv`: equilibrium biomass values for
 varying plant productivity. comma-separated values with `grid` (string: R,
 P, H, `eq` or `eq_guess`), `a`, `r`, `ex`. When `grid` is R, P or H, `ex`
 is the averaged biomass value at the end of simulations (see Methods) for
 Resource, Plant and Herbivore biomass, respectively. When `grid` is `eq`
 or `eq_guess`, `ex` is the inferred fixed point name. Inference is based
 on parameter values alone (for `eq`) or based on the proximity of R,P,H
 values to fixed point values from Eqs. S1 to S7 (for `eq_guess`).
 `eq_guess` is used in main manuscript figures (see
 `notebooks/report_figures.Rmd`). * `transects2.csv`: equilibrium biomass
 values for varying herbivory intensity. comma-separated values with same
 column variables as `transects1.csv`. Data files for supplementary figures
 include: * `timeseries.csv`: Example timeseries of simulating system (1).
 comma-separated values with `a`, `r`, `eq` (string: fixed point name), `t`
 (timepoint), `grid` (string: R, P or H for Resource, Plant or Herbivore
 biomass, respectively), `Z` (number: biomass value) *
 `si_discretized_lv.csv`: Timeseries of the simplified Plant-Herbivore
 system used in SI section 3. comma-separated values with `P` (Plant
 biomass), `H` (herbivore biomass), `p_id` (parameter combination id),
 sorted by increasing timepoint. ## Installation For Windows users (and
 Docker enthusiasts) that do not already have R, Julia and Quarto
 installed, I would recommend running the project inside a Docker container
 and mounting the output directories to paths on your computer (here
 `./output`) : ``` docker build -t resource-plant-herbivore . docker run
 -ti -v $(pwd)/container_output:/home/workspace/output -v
 $(pwd)/container_data:/home/workspace/data resource-plant-herbivore ``` If
 you prefer to use the docker volumes interface, you can use `docker volume
 create rph-output` and `-v rph-output:/home/workspace/output` instead to
 later access the created `rph-output` volume from Docker Desktop. ##
 Reproducing the analyses The following steps assume you have installed
 [Julia](https://docs.julialang.org/en/v1.12-dev/manual/installation/)
 version &gt;=1.11.2 as well as R &gt;=4.4. With Julia, run simulations : *
 start `julia` * `julia&gt; include("scripts/setup.jl")` activate
 the project * `julia&gt;
 include("scripts/generate_data_local.jl")` run local simulations
 (~ 5min first time and 2min afterwards) * `julia&gt;
 include("scripts/generate_data_si.jl")` for analyses from the
 Supporting information * exit julia With R, draw the figures * If
 you're not running the project from its dedicated container, run
 `R&gt; renv::restore()` to install required packages in the project
 library. You might need to also install external libraries. * `R&gt;
 rmarkdown::render("notebooks/report_figures.Rmd", output_dir =
 "output")` generate a .html with all report figures. Figures are
 also saved as pdf in `output/figs` The Supporting information document can
 be built with [Quarto](https://quarto.org/docs/get-started/): `quarto
 render notebooks/supplement.qmd --output-dir ../output`. ## Browsing code
 Resource-Plant-Herbivore.jl is just a wrapper project to handle R and
 Julia environments more easily. Source code for the actual model is
 located in its own Julia module, in `packages/LocalRPHModel.jl`. To get
 access to `?` docstrings of functions in `LocalRPHModel.jl`, you can build
 its documentation from the `Resource-Plant-Herbivore.jl` root : ```
 julia&gt; include("./packages/LocalRPHModel.jl/docs/make.jl)
 julia&gt; ?LocalRPHModel.traj ```