Introduction to spleenrbc

library(spleenrbc, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(tidyr)
library(ggplot2)

The baseline_parameters() function returns a list of parameter values for the given Plasmodium species.

pf_params <- baseline_parameters(species = "Pf")
pv_params <- baseline_parameters(species = "Pv")

You can modify the parameter values to reflect different scenarios.

# Increase the phagocytosis rate for infected RBCs by 10%.
pf_mod_params <- baseline_parameters(species = "Pf")
pf_mod_params$lambdaI.sel <- 1.1 * pf_mod_params$lambdaI.sel

# No initial parasites, so the model should remain at homeostasis.
no_inf_params <- baseline_parameters(species = "Pf")
no_inf_params$I_t_1 <- 0

The run_spleenrbc() function accepts a parameter list, or a data frame where each row contains the parameters for a separate scenario. It simulates the model for each scenario, and returns the results as a data frame.

pf_results <- run_spleenrbc(pf_params, days = 50)
pv_results <- run_spleenrbc(pv_params, days = 50)
pf_mod_results <- run_spleenrbc(pf_mod_params, days = 50)
no_inf_results <- run_spleenrbc(no_inf_params, days = 50)

# Collect the results of each scenario into a single data frame.
results <- bind_rows(
  pf_results |>
    mutate(scenario = "Pf (baseline)"),
  pv_results |>
    mutate(scenario = "Pv (baseline)"),
  pf_mod_results |>
    mutate(scenario = "Pf (increased phagocytosis)"),
  no_inf_results |>
    mutate(scenario = "No infection")
) |>
  pivot_longer(! c(scenario, time))

You can then plot model quantities, such as the number of uninfected RBCs in the circulation or in the spleen, for each scenario.

ggplot(
  results |> filter(name == "U_t"),
  aes(time / 24, value, colour = scenario)
) +
  geom_line() +
  scale_colour_hue(name = NULL) +
  xlab("Time (days)") +
  scale_y_log10("Uninfected RBCs in the circulation")
Circulating uRBC populations for different scenarios.

Circulating uRBC populations for different scenarios.

ggplot(
  results |> filter(name == "Ur_t"),
  aes(time / 24, value, colour = scenario)
) +
  geom_line() +
  scale_colour_hue(name = NULL) +
  xlab("Time (days)") +
  scale_y_log10("Uninfected RBCs in the spleen")
Splenic uRBC populations for different scenarios.

Splenic uRBC populations for different scenarios.