This repository contains a mathematical model of red blood cell (RBC) dynamics in a malaria infection. This model includes the spleen as a separate model compartment that can retain large amounts of infected and uninfected RBCs.
See the online documentation for vignettes and reference materials.
Installation
The model is implemented in R and provided as an R package called spleenrbc
. The simplest way to install this package is:
install.packages("spleenrbc", repos = "https://robmoss.runiverse.dev")
library(spleenrbc)
You will then be able to run the baseline model scenarios, and define and run your own model scenarios. See the provided package documentation and vignettes for examples.
Running simulations and plotting results
The simulation and plotting scripts are not included in the package itself. In order to run them, you will need to clone this repository:
git clone https://gitlab.unimelb.edu.au/rgmoss/malariaspleenrbcloss.git
cd malariaspleenrbcloss
Running simulations
There are scripts to run the following simulations:

runbaselinescenarios.R
: using the baseline model parameters, run a single simulation for the following scenarios: No infection;
 Pf infection; and
 Pv infection.
runsensitivityanalysis.R
: run 1000 simulations for Pf infections and 1000 simulations for Pv infections. Both sets of simulations use Latin hypercube sampling (LHS) and vary 18 of the baseline parameters by +/ 20%. Note that this may take around 2 hours to complete.
Code structure
The model implementation is divided into multiple R
files:

Model parameters:
parameters.R
provides functions that return baseline parameter values (baseline_parameters
) and calculate values for dependent parameters (define_derived_parameters
).homeostasis.R
provides a function that calculates the reticulocyte production rate and red blood cell populations at homeostasis, in the absence of a malaria infection (retic_steady_state
).

Model state:
state.R
provides functions that create the initial model state (initial_spleenrbc_state
), simulate the model forward one timestep (step_spleenrbc_model
), and perform an entire model simulation (run_spleenrbc_model
).rate_functions.R
provides functions that calculate the timevarying rates that govern the movement and destruction of red blood cells in the model.

Simulation outputs:

outputs.R
provides functions that record key outputs of a each simulation (individual_results
), and calculate derived quantities of interest (infection_flows_and_loss
,calculate_irbc_ratio
,credible_intervals
,rbc_counts_to_haemoglobin
).


Running model simulations:
run.R
provides a function for running multiple model simulations (run_spleenrbc
).sensitivity.R
provides functions that define sampling distributions for the sensitivity analysis (lhs_distributions
) and draw parameter samples for the sensitivity analysis (sample_parameters
).