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

Hide folded code blocks when exporting to PDF

We now also correctly describe gamma as the normoblast production rate,
rather than the normoblast population.

Citing Koepke and Koepke in the caption for Figure 6 required defining
different captions for HTML and PDF output, and adding a citation
elsewhere in the document.
parent ae84da7f
Branches
No related tags found
No related merge requests found
Pipeline #134182 passed
......@@ -150,7 +150,7 @@ For convenience, we also define terms for the total RBC populations in the circu
Some model parameters are defined relative to the steady-state (homeostasis) in the absence of a malaria infection, where the circulating reticulocyte and normocyte populations — \(\rc\) and \(\nc\), respectively — are equal to the steady-state RBC population \(\Uss\).
The value of \(\Uss\) is the median RBC count (in the circulation) for patients with no fever (`fever24 == 0`) or malaria infection (`Species == 0`).
```{r setup, class.source = 'fold-hide'}
```{r setup, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), echo = ! knitr::is_latex_output()}
library(spleenrbc, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(tidyr)
......@@ -162,7 +162,7 @@ utils::data("rbc_steady_state", package = "spleenrbc")
rbc_steady_state
```
We use a root-finding method to solve the following conservation equation for the initial normoblast population \(\gamma\) *in the absence of a malaria infection*:
We use a root-finding method to solve the following conservation equation for the normoblast production rate \(\gamma\) *in the absence of a malaria infection*:
\begin{align}
\Uss &\approx \sum_a N_c(a) + \sum_a R_c(a) : n(a) = \gamma
......@@ -187,7 +187,7 @@ pcnt_in_spleen <- 100 * rbc_spleen / (rbc_spleen + rbc_circ)
cat("Retained RBCs:", sprintf("%0.2f%%", pcnt_in_spleen), "\n")
```
```{r net_rbc_popns, class.source = 'fold-hide'}
```{r net_rbc_popns, class.source = 'fold-hide', echo = ! knitr::is_latex_output()}
net_n <- p$gamma * p$T_n
net_r <- sum(p$r_a_ss)
net_R <- sum(p$R_a_ss)
......@@ -240,7 +240,7 @@ We start with a small number \(I_0\) of infected RBCs in the circulation, with a
The initial cell populations for the baseline parameter values are shown in Figures \@ref(fig:nr0), \@ref(fig:U0), and \@ref(fig:I0).
```{r nr0, class.source = 'fold-hide', fig.cap = 'Initial cell populations in the bone marrow.'}
```{r nr0, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Initial cell populations in the bone marrow.'}
df_nr0 <- data.frame(
age = c(1:(p$T_n + p$T_R)),
value = c(s0$n_at_1, s0$r_at_1),
......@@ -254,7 +254,7 @@ ggplot(df_nr0, aes(age / 24, value, colour = what)) +
theme(legend.position = "top")
```
```{r U0, class.source = 'fold-hide', fig.cap = 'Initial uninfected RBC populations.'}
```{r U0, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Initial uninfected RBC populations.'}
df_u0 <- data.frame(
age = rep(1:p$T_urbc, 2),
value = c(s0$U_at_1, s0$Ur_at_1),
......@@ -275,7 +275,7 @@ ggplot(df_u0[df_u0$value > 0, ],
theme(legend.position = "top")
```
```{r I0, class.source = 'fold-hide', fig.cap = 'Initial infected RBC populations.'}
```{r I0, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Initial infected RBC populations.'}
df_i0 <- data.frame(
age = rep(1:p$T_irbc, 3),
value = c(s0$I_at_1, s0$Ir_at_1, s0$Iq_at_1),
......@@ -294,7 +294,7 @@ ggplot(df_i0, aes(age, value, colour = where)) +
\clearpage
# RBC production in the bone marrow
The normoblast production rate depends on the population of circulating uninfected RBCs \(\Ucnet\), the steady-state uninfected RBC population \(\Uss\), the steady-state normoblast population \(\gamma\), and the threshold parameter \(U_c^l\):
The normoblast production rate depends on the population of circulating uninfected RBCs \(\Ucnet\), the steady-state uninfected RBC population \(\Uss\), the steady-state normoblast production rate \(\gamma\), and the threshold parameter \(U_c^l\):
\begin{align}
U_l &= U_c^l \cdot \Uss
......@@ -308,7 +308,7 @@ The normoblast production rate depends on the population of circulating uninfect
| Symbol | Description | Baseline value |
|--------------------|------------------------------------|-------------------|
| \(\gamma\) | Steady-state normoblast population | \(`r p$gamma`\) |
| \(\gamma\) | Steady-state normoblast production | \(`r p$gamma`\) |
| \(U_c^l\) | Threshold parameter | \(`r p$consUl`\) |
| \(f_\mathrm{max}\) | Scaling parameter | \(`r p$MaxFold`\) |
| \(e_\mathrm{sl}\) | Slope parameter | \(`r p$slope_e`\) |
......@@ -317,7 +317,7 @@ Table: Model parameters for erythropoiesis.
Our chosen value of \(f_\mathrm{max}\) is consistent with a previous modelling study [@Watson17], which noted that "in extreme anaemia [RBC production] can be increased fivefold or more", and produced model fits where RBC production was increased almost ten-fold.
```{r eryth, class.source = 'fold-hide', fig.cap = 'The erythropoiesis rate varies from \\(\\gamma\\) to \\(f_\\mathrm{max} \\cdot \\gamma\\).'}
```{r eryth, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The erythropoiesis rate varies from \\(\\gamma\\) to \\(f_\\mathrm{max} \\cdot \\gamma\\).'}
rbc_frac_ss <- seq(0, 1, by = 1e-3)
df_eryth <- data.frame(
rbc_pcnt_ss = 100 * rbc_frac_ss,
......@@ -392,7 +392,17 @@ The normoblast and reticulocyte populations in the bone marrow age over time, an
Table: Model parameters for bone marrow cell equations.
```{r rho, class.source = 'fold-hide', fig.cap = 'The minimum age at which reticulocytes are released from the bone marrow. Point estimates are from Figure 2 of @Koepke86.'}
These parameters were calibrated using data from @Koepke86, as shown in Figure \@ref(fig:rho).
```{r rho_fig_cap, echo = FALSE}
if (knitr::is_latex_output()) {
rho_caption <- 'The minimum age at which reticulocytes are released from the bone marrow. Point estimates are from Figure 2 of Koepke and Koepke (\\citeproc{ref-Koepke86}{1986}).'
} else {
rho_caption <- 'The minimum age at which reticulocytes are released from the bone marrow. Point estimates are from Figure 2 of @Koepke86.'
}
```
```{r rho, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = rho_caption}
rbc_frac_ss <- seq(0, 1.25, by = 1e-3)
df_rho_age <- data.frame(
rbc_pcnt_ss = 100 * rbc_frac_ss,
......@@ -461,7 +471,7 @@ We denote the number of uRBCs removed in a time-step as \(U_{c \to r}\):
U_{c \to r}(a, t) &= \Uc[-1] \cdot (1 - \exp[-\delta_u(a, t)])
\end{align}
```{r deltauinner, class.source = 'fold-hide', fig.cap = 'The uRBC removal rate \\(\\delta_u(a, t)\\) from the circulation into the spleen when the scaling factor \\(F_U = 1\\).'}
```{r deltauinner, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The uRBC removal rate \\(\\delta_u(a, t)\\) from the circulation into the spleen when the scaling factor \\(F_U = 1\\).'}
df_du1 <- data.frame(
age = 1:p$T_urbc,
value = delta_u(p, 1:p$T_urbc)
......@@ -472,7 +482,7 @@ ggplot(df_du1, aes(age / 24, value)) +
ylab("Removal rate (unscaled)")
```
```{r deltaufold, class.source = 'fold-hide', fig.cap = 'The fold increase in uRBC removal rate due to the presence of iRBCs in the circulation, shown for \\(\\Ucnet = \\Uss\\).'}
```{r deltaufold, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The fold increase in uRBC removal rate due to the presence of iRBCs in the circulation, shown for \\(\\Ucnet = \\Uss\\).'}
ic_values <- 10^seq(3, 9, by = 0.1)
df_du_fold <- data.frame(
ic = ic_values,
......@@ -511,7 +521,7 @@ We denote the number of uRBCs released in a time-step as \(U_{r \to c}\):
\cdot (1 - \exp[-\delta'_u(a)])
\end{align}
```{r deltauprime, class.source = 'fold-hide', fig.cap = "The uRBC release rate \\(\\delta'_u(a, t)\\) from the spleen into the circulation."}
```{r deltauprime, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = "The uRBC release rate \\(\\delta'_u(a, t)\\) from the spleen into the circulation."}
df_duprime <- data.frame(
age = 1:p$T_urbc,
value = delta_u_prime(p, 1:p$T_urbc)
......@@ -571,7 +581,7 @@ We can then define the total number of infected RBCs in the circulation and in t
| \(\mathrm{PMF}\) | Parasite multiplication factor | \(`r p$PMF`\) |
| \(\omega\) | Proportion of merozoites released in the spleen that infect circulating uRBCS | \(`r p$w_rc`\) |
```{r beta, class.source = 'fold-hide', fig.cap = 'The age-dependent merozoite preference for uninfected RBCs.'}
```{r beta, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The age-dependent merozoite preference for uninfected RBCs.'}
pv <- baseline_parameters(species = "Pv")
df_beta <- data.frame(
......@@ -629,7 +639,7 @@ We denote the number of iRBCs removed in a time-step as \(I_{c \to r}\):
I_{c \to r}(a, t) &= \Ic[-1] \cdot (1 - \exp[-\delta_i(a, t)])
\end{align}
```{r deltaiinner, class.source = 'fold-hide', fig.cap = 'The iRBC removal rate \\(\\delta_i(a, t)\\) from the circulation into the spleen when the scaling factor \\(F_I = 1\\).'}
```{r deltaiinner, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The iRBC removal rate \\(\\delta_i(a, t)\\) from the circulation into the spleen when the scaling factor \\(F_I = 1\\).'}
df_di1 <- data.frame(
age = 1:p$T_irbc,
value = delta_i(p, 1:p$T_irbc)
......@@ -644,7 +654,7 @@ ggplot(df_di1, aes(age, value)) +
)
```
```{r deltaifold, class.source = 'fold-hide', fig.cap = 'The fold increase in iRBC removal rate due to the presence of iRBCs in the circulation, shown for \\(\\Ucnet = \\Uss\\).'}
```{r deltaifold, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The fold increase in iRBC removal rate due to the presence of iRBCs in the circulation, shown for \\(\\Ucnet = \\Uss\\).'}
ic_values <- 10^seq(6, 12, by = 0.1)
df_di_fold <- data.frame(
ic = ic_values,
......@@ -692,7 +702,7 @@ We denote the number of iRBCs released in a time-step as \(I_{r \to c}\):
\cdot (1 - \exp[-\delta'_i(a)])
\end{align}
```{r deltaiprime, class.source = 'fold-hide', fig.cap = "The iRBC release rate \\(\\delta'_i(a)\\) from the spleen into the circulation."}
```{r deltaiprime, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = "The iRBC release rate \\(\\delta'_i(a)\\) from the spleen into the circulation."}
df_dip <- data.frame(
age = 1:p$T_irbc,
value = delta_i_prime(p, 1:p$T_irbc)
......@@ -734,7 +744,7 @@ We denote the number of iRBCs sequestered in a time-step as \(I_{c \to q}\):
| \(\zeta_{\mathrm{sl}}\) | Slope parameter | \(`r p$zeta_sl`\) |
| \(\zeta_{50}\) | Half-maximal age | \(`r p$zeta_a50`\) hours |
```{r zeta, class.source = 'fold-hide', fig.cap = 'The age-specific probability of iRBC sequestration.'}
```{r zeta, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The age-specific probability of iRBC sequestration.'}
p_pv <- baseline_parameters("Pv")
df_zeta <- data.frame(
age = rep(1:p$T_irbc, 2),
......@@ -863,7 +873,7 @@ where:
\clearpage
# Baseline outputs: no infection
```{r baseline-ninf-urbc, class.source = 'fold-hide', fig.cap = 'RBC populations over time for the baseline parameter values (no infection).'}
```{r baseline-ninf-urbc, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'RBC populations over time for the baseline parameter values (no infection).'}
bni_scenario <- baseline_parameters("Pf", derived = FALSE) |>
as.data.frame() |>
mutate(I_t_1 = 0)
......@@ -886,7 +896,7 @@ ggplot(df_bni |> filter(name %in% c("U_t", "Ur_t")),
theme(legend.text = element_text(margin = margin(r = 12)))
```
```{r baseline-ninf-ur-frac, class.source = 'fold-hide', fig.cap = 'Uninfected RBC retention in the spleen (no infection).'}
```{r baseline-ninf-ur-frac, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Uninfected RBC retention in the spleen (no infection).'}
ggplot(df_bni |> filter(name == "Ur_frac_U"),
aes(time / 24, 100 * value)) +
geom_line() +
......@@ -897,7 +907,7 @@ ggplot(df_bni |> filter(name == "Ur_frac_U"),
\clearpage
# Baseline outputs: Pf
```{r baseline-pf-urbc, class.source = 'fold-hide', fig.cap = 'RBC populations over time for the baseline parameter values (Pf infection).'}
```{r baseline-pf-urbc, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'RBC populations over time for the baseline parameter values (Pf infection).'}
bpf_scenario <- baseline_parameters("Pf")
df_bpf <- run_spleenrbc(bpf_scenario) |>
mutate(
......@@ -924,7 +934,7 @@ ggplot(df_bpf |> filter(name %in% c("U_t", "Ur_t", "I_t", "Ir_t")),
theme(legend.text = element_text(margin = margin(r = 12)))
```
```{r baseline-pf-ur-frac, class.source = 'fold-hide', fig.cap = 'Uninfected RBC retention in the spleen (Pf infection).'}
```{r baseline-pf-ur-frac, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Uninfected RBC retention in the spleen (Pf infection).'}
ggplot(df_bpf |> filter(name == "Ur_frac_U"),
aes(time / 24, 100 * value)) +
geom_line() +
......@@ -932,7 +942,7 @@ ggplot(df_bpf |> filter(name == "Ur_frac_U"),
ylab("uRBC retention in the spleen (%)")
```
```{r baseline-pf-u-infs, class.source = 'fold-hide', fig.cap = 'Uninfected RBC loss due to malaria, by infection and by retention in the spleen (Pf infection).'}
```{r baseline-pf-u-infs, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Uninfected RBC loss due to malaria, by infection and by retention in the spleen (Pf infection).'}
ggplot(df_bpf |> filter(name %in% c("inf_total", "inf_from_icq",
"inf_from_ir", "flow_uc_to_r_inf")),
aes(time / 24, value, colour = name)) +
......@@ -951,7 +961,7 @@ ggplot(df_bpf |> filter(name %in% c("inf_total", "inf_from_icq",
theme(legend.text = element_text(margin = margin(r = 12)))
```
```{r baseline-pf-irbc-ratio, class.source = 'fold-hide', fig.cap = 'The ratio of (a) the proportion of RBCs in the spleen that are infected; to (b) the proportion of RBCs in the circulation that are infected (Pf infection).'}
```{r baseline-pf-irbc-ratio, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The ratio of (a) the proportion of RBCs in the spleen that are infected; to (b) the proportion of RBCs in the circulation that are infected (Pf infection).'}
ggplot(df_bpf |> filter(name == "iRBC_Ratio"),
aes(time / 24, value)) +
geom_line() +
......@@ -963,7 +973,7 @@ ggplot(df_bpf |> filter(name == "iRBC_Ratio"),
\clearpage
# Baseline outputs: Pv
```{r baseline-pv-urbc, class.source = 'fold-hide', fig.cap = 'RBC populations over time for the baseline parameter values (Pv infection).'}
```{r baseline-pv-urbc, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'RBC populations over time for the baseline parameter values (Pv infection).'}
bpv_scenario <- baseline_parameters("Pv")
df_bpv <- run_spleenrbc(bpv_scenario) |>
mutate(
......@@ -990,7 +1000,7 @@ ggplot(df_bpv |> filter(name %in% c("U_t", "Ur_t", "I_t", "Ir_t")),
theme(legend.text = element_text(margin = margin(r = 12)))
```
```{r baseline-pv-ur-frac, class.source = 'fold-hide', fig.cap = 'Uninfected RBC retention in the spleen (Pv infection).'}
```{r baseline-pv-ur-frac, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Uninfected RBC retention in the spleen (Pv infection).'}
ggplot(df_bpv |> filter(name == "Ur_frac_U"),
aes(time / 24, 100 * value)) +
geom_line() +
......@@ -998,7 +1008,7 @@ ggplot(df_bpv |> filter(name == "Ur_frac_U"),
ylab("uRBC retention in the spleen (%)")
```
```{r baseline-pv-u-infs, class.source = 'fold-hide', fig.cap = 'Uninfected RBC loss due to malaria, by infection and by retention in the spleen (Pv infection).'}
```{r baseline-pv-u-infs, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'Uninfected RBC loss due to malaria, by infection and by retention in the spleen (Pv infection).'}
ggplot(df_bpv |> filter(name %in% c("inf_total", "inf_from_icq",
"inf_from_ir", "flow_uc_to_r_inf")),
aes(time / 24, value, colour = name)) +
......@@ -1016,7 +1026,7 @@ ggplot(df_bpv |> filter(name %in% c("inf_total", "inf_from_icq",
theme(legend.text = element_text(margin = margin(r = 12)))
```
```{r baseline-pv-irbc-ratio, class.source = 'fold-hide', fig.cap = 'The ratio of (a) the proportion of RBCs in the spleen that are infected; to (b) the proportion of RBCs in the circulation that are infected (Pv infection).'}
```{r baseline-pv-irbc-ratio, class.source = 'fold-hide', echo = ! knitr::is_latex_output(), fig.cap = 'The ratio of (a) the proportion of RBCs in the spleen that are infected; to (b) the proportion of RBCs in the circulation that are infected (Pv infection).'}
ggplot(df_bpv |> filter(name == "iRBC_Ratio"),
aes(time / 24, value)) +
geom_line() +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment