Scripts and data for: Integrating different facets of diversity into food web models: how adaptation among and within functional groups shape ecosystem functioning
Cite this dataset
Wojcik, Laurie Anne et al. (2024). Scripts and data for: Integrating different facets of diversity into food web models: how adaptation among and within functional groups shape ecosystem functioning [Dataset]. Dryad. https://doi.org/10.5061/dryad.ttdz08m4x
Abstract
Adaptation of communities to environmental fluctuations can emerge from different facets of biodiversity, which may impact ecosystem functioning differently. Previous work examined how ecosystem functions can be influenced by two sources of adaptive potential: sorting (i.e., changes in community composition due to fitness differences) can occur when multiple species or groups are present (richness), and trait adaptability (i.e., trait adjustments within species or functional groups) can emerge from genetic or phenotypic diversity. However, their effect is typically studied separately, and often in the context of only one trophic level. Therefore, we used a bitrophic trait-based model varying in richness and in the presence of trait adaptability at each trophic level, to investigate how sorting and trait adaptability, at one or two trophic levels, separately or jointly shape ecosystem functions. We found that the adaptive potential emerging from any facet of diversity-induced changes in trophic interactions, in turn, affects biomass distributions within and across trophic levels, dynamical behaviour, and synchrony of biomass dynamics within a trophic level. Particularly, sorting and trait adaptability could contribute to a similar degree and at a similar time to temporal changes in ecosystem functions, but their respective contribution depended on the speed of trait adaptation, the trait range between similar functional groups, and trophic interactions. We thus suggest to consider multiple facets of diversity and their corresponding sources of adaptive potential to deepen our mechanistic understanding of ecosystem functioning, especially in a context of rapid biodiversity change.
README: Scripts and data for: Integrating different facets of diversity into food web models: how adaptation among and within functional groups shape ecosystem functioning
https://doi.org/10.5061/dryad.ttdz08m4x
Note that biomasses are expressed in mg C m-3 and traits are unitless.
Tasks performed by the python and C scripts
Generating time series and computing ecosystem functions and properties
To generate biomass and trait time series of a particular food web, we executed the file get_timeseries_ecosystem_functions.py. This Python script performed several tasks: (a) setting the parametrisation of the model, (b) calling and executing the file get_timeseries_ecosystem_functions (produced by compiling get_timeseries_ecosystem_functions.c; cf details later), which solved the model's equations and generated the biomass and trait time series by using the parametrisation defined in python, and (c) computing the temporal means and the coefficient of variation of the ecosystem functions and properties.
For each parametrisation, a certain number of randomly-initialised simulations were run (n_duplicates) and the previous tasks (a,b and c) were performed for each simulation. To distinguish between different simulations of different parametrisations, we then used an ID number composed of 7 digits: the first digit refers to the number of prey (between 1 and 5), the second digit refers to the number of predators (between 1 and 5), the third digit indicates whether adaptation within prey functional groups is enabled (1) or disabled (0), the fourth digit indicates whether adaptation within prey functional groups is enabled (1) or disabled (0), the last four digits correspond to the number of the simulation of a given parametrisation (if n_duplicates=200, this number varies between 1 and 200). This ID number was used to name the timeseries files "timeseries_{IDsim}.txt", where IDsim is the ID number of the simulation. Thus, "timeseries_5310054.txt" was the biomass and trait timeseries of simulation 54 corresponding to a food web with 5 prey functional groups and 3 predator functional groups where adaptation within prey groups was enabled and adaptation within predator groups was disabled.
For each parametrisation, we gathered the temporal means and the coefficient of variation of the ecosystem functions and properties of each associated simulation into a single numpy dataframe and saved it into a .npy format. We named the file "outputs_nduplicates{x}_ {IDparam}.npy", where x is the total number of simulations run (e.g. 200) and IDparam is composed of 4 digits: the first digit refers to the number of prey (between 1 and 5), the second digit refers to the number of predators (between 1 and 5), the third digit indicates whether adaptation within prey functional groups is enabled (1) or disabled (0), the fourth digit indicates whether adaptation within prey functional groups is enabled (1) or disabled (0).
Analysing results and producing figures
We analysed the results and produced figures using the python script data_analyses_and_plots.py.
Folder and files structure
In the main folder you can find all the python and C scripts and two subfolders data and figures.
Folders structure
The subfolder data is divided into subsubfolders named "vP{x}vH{y}", where {x} and {y} refers to the values of vP and vH multiplied by 100. vP and vH are the parameters determining the speed of trait of adaptation of prey and predators, respectively (cf. detailed information in the associated article). Typically, we simulated four scenarios where vP=0.06 and vH=0.02 ("vP6_vH2"), vP=0.6 and vH=0.06 ("vP60_vH6") , vP=0.6 and vH=0.2 ("vP60_vH20") or vP=0.6 and vH=0.6 ("vP60_vH60"). In each subfolder, there are the timeseries files of each simulation and parametrisation ( "timeseries{IDsim}.txt"), and the .npy files gathering the temporal means and the coefficient of variation of the ecosystem functions and properties of each associated simulation for a given parametrisation ("outputs_nduplicates{x}_ {IDparam}.npy").
The subfolder figure is also divided into four subsubfolders following the naming "vP{x}_vH{y}", and contains all the figures generated with the script data_analyses_and_plots.py.
Files structure
The number of columns in the data files generated with the python and C scripts depend on the number of prey functional groups (nP) and the number of predator functional groups (nH).
The timeseries files ( "timeseries_{IDsim}.txt") present by column order: the timestep, solver crash (0 if no crash or -1 otherwise), nP, nH, adaptation within prey functional groups (boolean 0: disabled and 1: enabled; named wP), adaptation within predator functional groups (boolean 0: disabled and 1: enabled; named wH), IDsim, the biomasses of each nP and nH groups, (across nP+nH columns), the trait values of each nP and nH groups (across nP+nH columns).
The .npy files ("outputs_nduplicates{x}_ {IDparam}.npy") present by column order: nP, nH, wP, wH, IDsim, the biomasses of each nP and nH groups, the trait values of each nP and nH groups at the initialisation (across nP+nH columns), the minimal biomasses reached by each nP and nH groups once the system settled on its attractor (across nP+nH columns), the minimal trait values reached by each nP and nH groups once the system settled on its attractor (across nP+nH columns), the maximal biomasses reached by each nP and nH groups once the system settled on its attractor (across nP+nH columns), the maximal trait values reached by each nP and nH groups once the system settled on its attractor (across nP+nH columns), the temporal mean of the realised number of prey groups, the CV of the realised number of prey groups, the temporal mean of total prey biomass, the CV of total prey biomass, the synchrony of prey biomass dynamics, the temporal mean of prey production, the CV of prey production, the temporal mean of the biomass-weighted mean prey edibility at the trophic level, the CV of the biomass-weighted mean prey edibility at the trophic level, the temporal mean of the realised number of predator groups, the CV of the realised number predators, the temporal mean of total predator biomass, the CV of total predator biomass, the synchrony of predator biomass dynamics, the temporal mean of predator production, the CV of predator production, the temporal mean of the biomass-weighted mean predator selectivity at the trophic level, the CV of the biomass-weighted mean predator selectivity at the trophic level, the temporal mean of the relative top-down control of the prey trophic level, the CV of the relative top-down control of the prey trophic level, the temporal mean of the preference of the least selective predator for the least edible prey, the CV of the preference of the least selective predator for the least edible prey.
Software versions and packages
Before executing any C or python script, we first compiled the C script get_timeseries_ecosystem_functions.c by using the following command in the terminal: gcc -o get_timeseries_ecosystem_functions get_timeseries_ecosystem_functions.c -lm -lgsl -lgslcblas -lsundials_cvode -lsundials_nvecserial
. We notably used the SUNDIALS CVODE solver 5.7.0 to solve numerically the system of ordinary differential equations in C. We also used several packages in Python 3.10 among which NumPy, Pandas, and Matplotlib.
Methods
The datasets were generated and not collected in the field and the laboratory. We briefly summarise the methods used, which are extensively explained in the associated Oikos article. We solved numerically the ordinary differential equations of an an extended Rosenzweig-MacArthur predator-prey model in C using the SUNDIALS CVODE solver 5.7.0}. Then, we used several packages in Python 3.10 among which NumPy, Pandas, and Matplotlib to analyse the biomass and trait dynamics, and to quantify ecosystem functions. We notably compared the temporal means and variation (coefficient of variation) of ecosystem functions and properties (e.g. total biomass, production, biomass-weighted mean trait, synchrony of prey and predators, and the ratio between prey losses due to predation and the sum of prey losses due to competition and predation) of food webs with different sources of adaptive potential.
Funding
Deutsche Forschungsgemeinschaft, Award: GA 401/26-2, Priority Programme 1704: DynaTrait