Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: serocalculator
Title: Estimating Infection Rates from Serological Data
Version: 1.4.0.9009
Version: 1.4.0.9010
Authors@R: c(
person("Kristina", "Lai", , "kwlai@ucdavis.edu", role = c("aut", "cre")),
person("Chris", "Orwa", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Provides clear tables comparing old and new function names
- Includes code examples showing how to update existing code
- Accessible as a prominent tab in the website navigation

## Documentation

* Updated the methodology vignette to plot curve parameters via the `autoplot()` method.
## New features

* Added `cluster_var` and `stratum_var` parameters to `est_seroincidence()` and
Expand Down
6 changes: 3 additions & 3 deletions R/plot_curve_params_one_ab.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param n_curves how many curves to plot (see details).
#' @param n_points Number of points to interpolate along the x axis
#' (passed to [ggplot2::geom_function()])
#' @param iters_to_graph which MCMC iterations in `curve_params` to plot
#' @param iters_to_graph which rows of `object` to plot
#' (overrides `n_curves`).
#' @param alpha (passed to [ggplot2::geom_function()])
#' how transparent the curves should be:
Expand Down Expand Up @@ -71,8 +71,8 @@ plot_curve_params_one_ab <- function(
minor_breaks = NULL)
}

layer_function <- function(cur_iter) {
cur_params <- object |> filter(.data$iter == cur_iter)
layer_function <- function(cur_row) {
cur_params <- object[cur_row, ]
ggplot2::geom_function(
alpha = alpha,
fun = ab0,
Expand Down
2 changes: 1 addition & 1 deletion man/graph.curve.params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/graph_seroresponse_model_1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/plot_curve_params_one_ab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions tests/testthat/test-plot_curve_params_one_ab.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,31 @@ test_that("`plot_curve_params_one_ab()` produces consistent results", {
vdiffr::expect_doppelganger(title = "curve_r1")

})

test_that(
"`plot_curve_params_one_ab()` works when `iter` does not start at 1",
{
# Regression test: previously, layer_function filtered by
# `iter == cur_iter`, where cur_iter was a row index (1, 2, ...).
# When iter values didn't start at 1, the filter returned 0 rows,
# causing `r` to be numeric(0).
params <-
data.frame(
y0 = 10,
y1 = 10 ^ 4,
t1 = 9.5,
alpha = 0.01,
r = 1,
iter = 5,
antigen_iso = "test"
) |>
as_sr_params()

expect_no_error(
params |>
plot_curve_params_one_ab(n_points = 100,
xlim = c(0, 25),
log_y = FALSE)
)
}
)
6 changes: 4 additions & 2 deletions vignettes/articles/_antibody-response-model.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ curve1 <-
library(ggplot2)

curve1 |>
serocalculator:::plot_curve_params_one_ab(
log_y = FALSE
autoplot(
quantiles = NULL,
log_y = FALSE,
n_curves = 1
) +
xlim(0, 100) +
theme_minimal() +
Expand Down
Loading