des_rap_book

Step-by-step guide for building Python and R simulation models as part of a reproducible analytical pipeline (RAP).

https://github.com/pythonhealthdatascience/des_rap_book

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary
Last synced: 4 months ago · JSON representation ·

Repository

Step-by-step guide for building Python and R simulation models as part of a reproducible analytical pipeline (RAP).

Basic Info
Statistics
  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • Open Issues: 31
  • Releases: 0
Created 9 months ago · Last pushed 4 months ago
Metadata Files
Readme License Citation

README.md

# DES RAP Book: Reproducible Discrete-Event Simulation in Python and R [![Python](https://img.shields.io/badge/-Python_3.9.22-a8902b?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/) ![R 4.4.1](https://img.shields.io/badge/-R_4.4.1-276DC2?style=for-the-badge&logo=r&logoColor=white) ![Code licence](https://img.shields.io/badge/🛡️_Code_licence-MIT-8a00c2?style=for-the-badge&labelColor=gray) ![Text licence](https://img.shields.io/badge/🛡️_Text_licence-CC--BY--SA--4.0-b100cd?style=for-the-badge&labelColor=gray) [![ORCID](https://img.shields.io/badge/ORCID_Amy_Heather-0000--0002--6596--3479-A6CE39?style=for-the-badge&logo=orcid&logoColor=white)](https://orcid.org/0000-0002-6596-3479)


DES RAP Book is an open resource and website for building discrete-event simulation (DES) models within a reproducible analytical pipline (RAP), supporting the healthcare simulation community.

The resource demonstrates practical, code-based workflows and tools to help researchers and practitioners develop, validate, and share DES models in Python (SimPy) and R (simmer), ensuring models are reproducible.

Check it out at: https://pythonhealthdatascience.github.io/desrapbook/.


Who is this for?

  • Researchers, analysts, practitioners, and students in simulation modeling - especially those in healthcare and operations research.

  • Anyone using Python or R who is seeking practical guidance on best practices for reproducibility, with many of the sections (e.g. environments, version control, documentation, testing) being broadly relevant to any research software and data science projects.

  • Accessible to a range of experience levels. The material is designed to be approachable, though some familiarity with Python or R, and basic command line usage, is recommended. Prior experience with simulation modeling is also helpful.


What's covered?

  • Getting started: introduction to reproducibility and open-source.

  • Building models: Structured guidance on model inputs, implementation, experimentation, and analysis with clear, reproducible code examples in Python and R. This includes recommendations for experimentation, output analysis, and verification and validation.

  • Best practices: Code packaging, environment management, version control, linting, testing, and documentation for robust and transparent workflows.

  • Reporting and collaboration: Generating tables/figures, licensing, sharing, peer review, archiving, citation, and changelogs.


Getting started/Navigation


STARS

This resource has been developed as part of the project STARS: Sharing Tools and Artefacts for Reproducible Simulations in healthcare.

The project tackles the challenges of sharing, reusing, and reproducing discrete event simulation (DES) models in healthcare. Our goal is to create open resources using the two most popular open-source languages for DES: Python and R.

We have been developing tutorials, code examples, and tools to help researchers and practitioners develop, validate, and share DES models more effectively.

For more information on this project, check out the STARS page in the DES RAP Book.


View locally

This website is created using Quarto and hosted on GitHub pages. You can view the site locally. With quarto installed, you will need to:

1. Build the python environment

conda env create --file environment.yaml conda activate des-rap-book

2. Build the R environment

renv::init() renv::restore()

3. Create the book.

quarto render

Common reticulate error and solution

When rendering a Quarto document containing executable python code with reticulate, you might encounter:

Error in `use_condaenv()`: ! Unable to locate conda environment 'des-rap-book'. Backtrace: ▆ 1. └─reticulate::use_condaenv("des-rap-book", required = TRUE)

This can occur when multiple Conda or Mamba installations exist (e.g. mambgaforge, miniconda3), or if R is using a different search path than the shell. By default, reticulate only looks in one location for environments, which can cause problems when environments are not where reticulate expects.

To fix this, set the RETICULATE_CONDA environment variable to the correct Conda or Mamba executable. To find the path to your executable, run:

conda env list

Look for your environment in the list. For example, if your environment is at /home/amy/mambaforge/envs/des-rap-book, then your Conda executable is likely at /home/amy/mambaforge/bin/conda.

Set the environment variable like so:

export RETICULATE_CONDA=/home/amy/mambaforge/bin/conda

Now render your book:

quarto render

To avoid needing to set RETICULATE_CONDA every time you open a new terminal, add the export command to an .Renviron file in your project directory. This file is not tracked by Git, and is specific to you. Create the file and add:

RETICULATE_CONDA=/home/amy/mambaforge/bin/conda


Citation

To cite this work, see the CITATION.cff file in this repository or use the "Cite this repository" button on GitHub.


Linting

To lint active Python and R code:

{.bash} bash lint.sh

Note: inactive code (i.e. code that does not get run when building the book) will not be linted - though the R linter will enforce a terminal newline at the end of each .qmd file.


Funding

This project is supported by the Medical Research Council [grant number MR/Z503915/1].

Owner

  • Name: pythonhealthdatascience
  • Login: pythonhealthdatascience
  • Kind: organization

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: "DES RAP Book: Reproducible Discrete-Event Simulation in Python and R"
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Amy
    family-names: Heather
    email: a.heather2@exeter.ac.uk
    affiliation: University of Exeter Medical School
    orcid: 'https://orcid.org/0000-0002-6596-3479'
  - given-names: Tom
    family-names: Monks
    email: t.m.w.monks@exeter.ac.uk
    affiliation: University of Exeter Medical School
    orcid: http://orcid.org/0000-0003-2631-4481
  - given-names: Nav
    family-names: Mustafee
    email: n.mustafee@exeter.ac.uk
    affiliation: University of Exeter Business School
    orcid: https://orcid.org/0000-0002-2204-8924
  - given-names: Alison
    family-names: Harper
    email: a.l.harper@exeter.ac.uk
    affiliation: University of Exeter Business School
    orcid: https://orcid.org/0000-0001-5274-5037
repository-code: 'https://github.com/pythonhealthdatascience/des_rap_book'
abstract: >-
  Step-by-step guide for building Python and R simulation
  models as part of a reproducible analytical pipeline
  (RAP).
keywords:
  - reproducible
  - python
  - r
  - simpy
  - simmer
  - rap
license: MIT

GitHub Events

Total
  • Issues event: 53
  • Watch event: 2
  • Delete event: 13
  • Issue comment event: 13
  • Public event: 1
  • Push event: 131
  • Pull request event: 32
  • Create event: 13
Last Year
  • Issues event: 53
  • Watch event: 2
  • Delete event: 13
  • Issue comment event: 13
  • Public event: 1
  • Push event: 131
  • Pull request event: 32
  • Create event: 13

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 39
  • Total pull requests: 20
  • Average time to close issues: 8 days
  • Average time to close pull requests: less than a minute
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.18
  • Average comments per pull request: 0.0
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 39
  • Pull requests: 20
  • Average time to close issues: 8 days
  • Average time to close pull requests: less than a minute
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.18
  • Average comments per pull request: 0.0
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • amyheather (39)
Pull Request Authors
  • amyheather (20)
Top Labels
Issue Labels
enhancement (14) bug (5) amend page (3) new page (3) documentation (2) peer review (1) refactor (1) invalid (1)
Pull Request Labels

Dependencies

.github/workflows/quarto_publish.yaml actions
  • actions/checkout v4 composite
  • quarto-dev/quarto-actions/publish v2 composite
  • quarto-dev/quarto-actions/setup v2 composite
environment.yaml pypi