Skip to content
Snippets Groups Projects
Commit b8c99c7a authored by Rob Moss's avatar Rob Moss
Browse files

Record uRBC loss ratios in sensitivity analyses

This is the ratio of uRBC loss (from circulation) to due (a) retention
in the spleen caused by the presence of a malarian infection; to (b)
parasitisation of uRBCs.
parent 8432684c
Branches
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ export(alpha_r)
export(baseline_parameters)
export(beta)
export(calculate_irbc_ratio)
export(calculate_urbc_loss_ratio)
export(credible_intervals)
export(define_derived_parameters)
export(delta_i)
......
......@@ -135,6 +135,36 @@ infection_flows_and_loss <- function(results) {
}
#' Calculate the ratio of (a) the unparasitised RBC loss due to malaria
#' (additional uRBC retention in the spleen); to (b) the parasitised RBC loss
#' due to RBC infection.
#'
#' @param results A dataframe of simulation results.
#'
#' @return
#' A dataframe that includes the following column, in addition to those in
#' `results`:
#'
#' \describe{
#' \item{uRBC_Loss_Ratio}{The ratio of uRBC loss (from the circulation) due
#' to splenic retention and due to parasitisation.}
#' }
#'
#' @export
calculate_urbc_loss_ratio <- function(results) {
results |> dplyr::mutate(
flow_uc_to_r_inf = flow_uc_to_r - flow_uc_to_r_no_inf,
inf_total = inf_from_ic + inf_from_iq + inf_from_ir,
uRBC_Loss_Ratio = dplyr::case_when(
inf_total > 0 ~ flow_uc_to_r_inf / inf_total,
.default = 0
),
flow_uc_to_r_inf,
inf_total = NULL
)
}
#' Calculate the ratio of (a) the fraction of RBCs in the spleen that are
#' infected; to (b) the fraction of RBCs in the circulation that are infected.
#'
......
......@@ -46,9 +46,23 @@ run_sensitivity_analysis <- function(species, days = 150, n_samples = 1000) {
# Save the credible intervals for all simulations.
cint_all_file <- file.path("outputs", paste0(prefix, "-rbc-cints-all.rds"))
cint_all <- results |>
select(scenario, time, U_t, Ur_t, I_t, Iq_t, Ir_t) |>
select(
scenario, time,
U_t, Ur_t, I_t, Iq_t, Ir_t,
flow_uc_to_r, flow_uc_to_r_no_inf,
inf_from_ic, inf_from_iq, inf_from_ir
) |>
# Calculate ratio of iRBC % in the spleen to iRBC % in the circulation.
calculate_irbc_ratio() |>
# Calculate ratio of unparasitised uRBC loss to parasitised uRBC loss.
calculate_urbc_loss_ratio() |>
# Drop intermediate values.
select(
scenario, time,
U_t, Ur_t, I_t, Iq_t, Ir_t,
iRBC_Ratio,
uRBC_Loss_Ratio
) |>
credible_intervals() |>
mutate(Species = !!species)
saveRDS(cint_all, cint_all_file)
......@@ -61,9 +75,23 @@ run_sensitivity_analysis <- function(species, days = 150, n_samples = 1000) {
cint_nonz_file <- file.path("outputs", paste0(prefix, "-rbc-cints-nonz.rds"))
cint_nonz <- results |>
filter(! scenario %in% zero_scenarios) |>
select(scenario, time, U_t, Ur_t, I_t, Iq_t, Ir_t) |>
select(
scenario, time,
U_t, Ur_t, I_t, Iq_t, Ir_t,
flow_uc_to_r, flow_uc_to_r_no_inf,
inf_from_ic, inf_from_iq, inf_from_ir
) |>
# Calculate ratio of iRBC % in the spleen to iRBC % in the circulation.
calculate_irbc_ratio() |>
# Calculate ratio of unparasitised uRBC loss to parasitised uRBC loss.
calculate_urbc_loss_ratio() |>
# Drop intermediate values.
select(
scenario, time,
U_t, Ur_t, I_t, Iq_t, Ir_t,
iRBC_Ratio,
uRBC_Loss_Ratio
) |>
credible_intervals() |>
mutate(Species = !!species)
saveRDS(cint_nonz, cint_nonz_file)
......@@ -72,9 +100,23 @@ run_sensitivity_analysis <- function(species, days = 150, n_samples = 1000) {
cint_zero_file <- file.path("outputs", paste0(prefix, "-rbc-cints-zero.rds"))
cint_zero <- results |>
filter(scenario %in% zero_scenarios) |>
select(scenario, time, U_t, Ur_t, I_t, Iq_t, Ir_t) |>
select(
scenario, time,
U_t, Ur_t, I_t, Iq_t, Ir_t,
flow_uc_to_r, flow_uc_to_r_no_inf,
inf_from_ic, inf_from_iq, inf_from_ir
) |>
# Calculate ratio of iRBC % in the spleen to iRBC % in the circulation.
calculate_irbc_ratio() |>
# Calculate ratio of unparasitised uRBC loss to parasitised uRBC loss.
calculate_urbc_loss_ratio() |>
# Drop intermediate values.
select(
scenario, time,
U_t, Ur_t, I_t, Iq_t, Ir_t,
iRBC_Ratio,
uRBC_Loss_Ratio
) |>
credible_intervals() |>
mutate(Species = !!species)
saveRDS(cint_zero, cint_zero_file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment