Rutger Kok, Sander Tans, Jeroen van Zon
Phys. Rev. E 108, 064403
This repository contains the code to reproduce the results of the above paper, as well as instructions for running your own simulations.
You only need Python and numpy to run the simulations. The scripts starting with fig_ reproduce the stated figure
panel(s). For example, fig_3abc_plot_two_compartment_intro.py reproduced Figure 3a-c.
importnumpyfromstem_cell_modelimporttoolsfromstem_cell_model.parametersimportSimulationParameters, SimulationConfigfromstem_cell_model.resultsimportMultiRunStatsfromstem_cell_model.two_compartment_model_spaceimportrun_simulation_nicheT= (16.153070175438597, 3.2357834505600382)
params=SimulationParameters.for_S_alpha_and_phi(S=1114, alpha_n=0.025, alpha_m=-0.275, phi=1.0, T=T, a=100/T[0])
random=numpy.random.Generator(numpy.random.MT19937(seed=1))
total_run_time=100000# Run the actual simulationrun_data=MultiRunStats()
whilerun_data.t_tot<total_run_time:
config=SimulationConfig(t_sim=total_run_time-run_data.t_tot, random=random)
results=run_simulation_niche(config, params)
run_data.add_results(results)
# Collect resultsstats=tools.get_single_parameter_set_statistics(run_data)The stats object has properties like stats.n_mean. You can store simulation results using Pickle and run_data.to_dict().
See for example two_compartment_model_sweep_well_mixed.py for a concise example. This scripts saves the results to a folder. It uses the stem_cell_model.sweeper module, which uses all cores of your PC.
Read back the results using stem_cell_model.sweeper.load_sweep_results(folder).
See the script profile_two_compartment.py for an example of how to use the cProfile module (built-in into Python). This module profiles your code, which shows you what parts are slow, and therefore helps you optimizing the code.