A consumer-resource modeling framework in a serial-dilution setup, where
Dynamics within each batch are given by 1:
The main feature of this framework is the inclusion of species adaptation to changing nutrient levels throughout the batch, by allowing the dynamics of the metabolic strategies, given by 2:
where
The framework includes a few adaptation models (i.e., different dynamical schemes for app__simulations.m
) that operate under these guidelines, and is receptible to the addition of different models that may work in this context. Note that this adaptation feature is based on the 2-nutrient case and thus is limited to
The dynamics are numerically solved for using MATLAB's built-in ode89
Runge-Kutta solver with adaptive step size. Simulations can be applied in a specific, instant manner, or by parallelly executing and collecting data from large sets of simulations, using the Split-Apply-Combine method (see below for protocol).
Note
Here, the general structure of this repository's Code section and workflow are described. For a more specific script description, look at each script specifically.
-
odefun.m
and theeventfun*.m
functions (one for each adaptation model) are the most basic functions, used byode89
as function handles to solve for the dynamics.odefun.m
contains the actual dynamics, while theeventfun*.m
functions are used to track events througout the dynamics. -
The
sim__*.m
functions carry out the actual simulations (for simulation types, seeapp__simulations.m
).sim__batch.m
is the most basic of these, which solves for the dynamics within each batch, and is executed by the other, highersim__*.m
functions (except forsim__invasibility_map.m
which uses it indirectly). All functions may optionally plot the results, and (except forsim__batch.m
) save the data. The high-end functionssim__serial__interbatch.m
,sim__serial__full_dynamics.m
, andsim__invasibility_map.m
are executed using the apply scripts (see below). -
The
app__*.m
scripts are the main scripts that apply the simulations, and are directly used by the user for setting parameter values and executing the simulations.app__simulations.m
is used for running specific simulations (single or several), whereas theapp__slurm__*.cmd
files are used for implementing large simulation sets in parallel (see below). -
The
plot__*.m
functions are used to plot the dynamics or other results (raw or collected data). Some are 'raw' plotters, which are used directly by thesim__*.m
functions to plot the results from a single simulation, and have a name corresponding to their simulation function. Others may collect the data from large sets of simulations, either by reading raw-data files or a collected-data table (in the case of inter-batch simulations).
A common approach to data-analysis, aiming to implement large simulation sets in an orderly and effective way:
-
Split - Produce a parameter table, such that each row contains values for all moving parameters (that vary between different simulations) for a certain simulation in the set, and a template-file to plug simulation parameters into.
This is done here by thesplit_runs__*.m
functions. -
Apply - Perform all jobs using a script that allocates resources and executes them independently in parallel. Each job uses the parameter template to plug values from a certain row in the split table, and performs a simulation. All set-simulations are directed to save raw data in the same directory.
This is done here by theapp__slurm__*.cmd
files. -
Combine - Collect data into a table synchronously from all saved raw-data files in the simulation set. Analyze/plot various dependencies.
Collecting is done here either by usingcollect_data__interbatch.m
in the case of inter-batch simulations, or directy by some of theplot__*.m
functions in other cases.
The power of this method is in its modular nature – jobs can be applied independently; data from existing files can be collected independently at any point in time, regardless of currently running jobs.
split_runs__*.m
app__slurm__*.cmd
collect_data__interbatch.m
* plot__*.m
* If needed
Data and corresponding figures are automatically saved with easily identifiable, corresponding file names (including the simulation type and important parameter values), in the Data and Plots directories, respectively. Their general structure is embedded and a generic sample of data and figures is included here inside both directories.
Here are some of these figures:
1 Adaptor - Metabolic Strategy distributions (Tip: to simulate a single species, use 2 identical species) Adaptor VS Non-Adaptor - Invasibility Character 2 Adaptors - Steady-State Populaion Bias VS Sensing TolerancesFootnotes
-
Amir Erez, Jaime G. Lopez, Benjamin G. Weiner, Yigal Meir, and Ned S. Wingreen. Nutrient levels and trade-offs control diversity in a serial dilution ecosystem. eLife, September 2020 (Go to paper). ↩
-
Amir Erez, Jaime G. Lopez, Yigal Meir, and Ned S. Wingreen. Enzyme regulation and mutation in a model serial-dilution ecosystem. Physical Review E, October 2021 (Go to papar). ↩