2. Using simChef to cook up simulations with MERITS
Overview of simChef
Case study: Interaction discovery with iRF
Why simulations?
Simulations are a powerful and ubiquitous tool in the modern scientific process.
They can be used to quickly
screen hypotheses and identify those worth pursuing
model natural systems under specific or rare conditions
stress-test emerging theories and methods
Importantly, simulations offer full control over experimental conditions.
What makes a “high-quality” simulation?
Building upon PCS, a “high-quality” simulation should be one with MERITS
M
Modular: written in self-contained and logically partitioned segments of code
E
Efficient: streamlined computationally and conceptually
R
Realistic: faithful to the natural world or realm of application, to the best extent allowed by established theory and/or available real-world data
I
Intuitive: sensible to the intended audience and a broad range of potential consumers, across all parts of the pipeline: simulation architecture, documentation, code, and analysis of results
T
Transparent: documented thoroughly and candidly
S
Stable: reproducible, replicable, and (potentially) generalizable beyond the scope of the simulation
How to create a simulation with MERITS?
Similar to cooking, crafting a simulation with MERITS requires careful planning!
Automated documentation and visualization of results
Caching of results
Ease of parallelization
Debugging tools
Built in library of evaluation and plotting functions
Creating your own simChef simulation
# create experiment recipeexperiment <-create_experiment(name ="My Experiment") |>add_dgp(my_dgp) |>add_method(my_method) |>add_evaluator(my_evaluator) |>add_visualizer(my_visualizer) |>add_vary_across(.dgp = my_dgp, n =c(10, 100, 1000))# run experimentmy_results <-run_experiment(experiment, n_reps =25, save =TRUE)# document and visualize experiment resultsinit_docs(experiment)render_docs(experiment)
DGP
the data-generating process from which to generate data
Method
the methods (or models) to fit in the simulation experiment
Evaluator
the evaluation metrics used to evaluate the methods’ performance
Visualizer
the visualization functions used to visualize the results (e.g., tables, plots, written text)
my_dgp <-create_dgp(.dgp_fun = dgp_fun, .name ="DGP Name",# named arguments to pass to .dgp_fun ...)
my_method <-create_method(.method_fun = method_fun, .name ="Method Name",# named arguments to pass to .method_fun ...)
my_evaluator <-create_evaluator(.eval_fun = eval_fun, .name ="Evaluator Name",# named arguments to pass to .eval_fun ...)
my_visualizer <-create_visualizer(.viz_fun = viz_fun, .name ="Visualizer Name",# named arguments to pass to .viz_fun ...)
Can have multiple DGPs, methods, evaluators, and visualizers
Can also add multiple DGP/methods parameters to vary across (e.g., sample size, signal-to-noise ratio, method hyperparameters, etc.)
Case Study: Interaction Discovery with iRF
Iterative Random Forests (iRF): computationally efficient tree-based method for detecting stable, high-order interactions in high-dimensional data (Basu et al. 2018)
Applications:
Transcription factor interactions in Drosophila embryos[1]
Chromatin interactions associated with alternative splicing[1]
Genetic interactions (epistasis) associated with red hair, multiple sclerosis,[2] and cardiac hypertrophy[3]
Chemical exposure interactions associated with child neurodevelopment[4]
prediction <- simChef::create_evaluator(.eval_fun = eval_summary,.name ="AUPRC",# named arguments to pass to eval_summaryeval_id ="auprc",eval_fun = eval_prediction)
fit_results and vary_params are automatically passed to the evaluator functions by simChef.