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

Tabulate parameters alphabetically, ignoring case

parent dffaf5a2
Branches
No related tags found
No related merge requests found
......@@ -32,23 +32,12 @@ suppressPackageStartupMessages(library(here))
output_dir <- here("outputs")
# Remove non-scalar derived parameters, such as the initial red blood cell
# populations.
remove_nonscalar_derived_parameters <- function(x) {
x[sapply(x, function(x) length(x) == 1)]
}
# Convert the baseline parameters for both species into data frames.
pf <- baseline_parameters(species = "Pf") |> #, derived = FALSE) |>
remove_nonscalar_derived_parameters() |>
as.data.frame() |>
dplyr::mutate(species = NULL, nospleen = NULL, Scenario = NULL) |>
tidyr::pivot_longer(everything(), names_to = "Parameter", values_to = "Pf")
pv <- baseline_parameters(species = "Pv") |> #, derived = FALSE) |>
remove_nonscalar_derived_parameters() |>
as.data.frame() |>
dplyr::mutate(species = NULL, nospleen = NULL, Scenario = NULL) |>
tidyr::pivot_longer(everything(), names_to = "Parameter", values_to = "Pv")
# Define how to format parameter values of different magnitudes.
format_value <- function(x, nsmall=4, min=1e-3, max=1e3) {
scientific <- x < min || x > max
......@@ -69,12 +58,40 @@ format_value <- function(x, nsmall=4, min=1e-3, max=1e3) {
}
}
# Join the baseline parameters into a single data frame.
baseline <- dplyr::inner_join(pf, pv, by = "Parameter") |>
dplyr::mutate(
Pf = sapply(Pf, format_value),
Pv = sapply(Pv, format_value)
)
# Return the baseline parameters for a species as a long data frame.
get_baseline_parameters <- function(species) {
baseline_parameters(species = species) |>
remove_nonscalar_derived_parameters() |>
as.data.frame() |>
dplyr::mutate(
species = NULL,
nospleen = NULL,
Scenario = NULL
) |>
tidyr::pivot_longer(
everything(),
names_to = "Parameter",
) |>
dplyr::mutate(
value = sapply(value, format_value)
)
}
# Convert the baseline parameters for both species into data frames.
baseline <- dplyr::inner_join(
get_baseline_parameters("Pf") |>
dplyr::rename(Pf = value),
get_baseline_parameters("Pv") |>
dplyr::rename(Pv = value),
by = "Parameter"
) |>
# Sort by parameter name (case-insensitive).
dplyr::arrange(tolower(Parameter)) |>
# Highlight parameters whose values differ between species.
dplyr::mutate(Parameter = dplyr::case_when(
.default = Parameter,
Pf != Pv ~ paste0("**", Parameter, "**")
))
```
```{r define-evidence, class.source = 'fold-hide'}
......@@ -83,10 +100,16 @@ baseline <- dplyr::inner_join(pf, pv, by = "Parameter") |>
baseline <- baseline |>
dplyr::mutate(Evidence = dplyr::case_when(
.default = "",
Parameter == "MaxFold" ~ "[Maximum fold increase in RBC production]" # "@Watson17"
Parameter == "MaxFold" ~ "[Maximum fold increase in RBC production]"
))
knitr::kable(baseline)
knitr::kable(
baseline,
caption=paste(
"Evidence for chosen parameter values.",
"Parameters that differ between species are shown **in bold**."
)
)
```
## Maximum fold increase in RBC production
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment