From a36d21e6df6cba598ba972a36524326613d84e5c Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Tue, 4 Feb 2025 17:54:03 -0800 Subject: [PATCH 1/5] restore `sim.cs()` and `sim.cs.multi()` to the export list --- NAMESPACE | 2 ++ R/sim_pop_data.R | 2 +- R/sim_pop_data_multi.R | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 2157add21..8678174b4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,6 +32,8 @@ export(load_noise_params) export(load_pop_data) export(log_likelihood) export(serocalculator_example) +export(sim.cs) +export(sim.cs.multi) export(sim_pop_data) export(sim_pop_data_multi) export(strata) diff --git a/R/sim_pop_data.R b/R/sim_pop_data.R index 322349203..9cd2e9314 100644 --- a/R/sim_pop_data.R +++ b/R/sim_pop_data.R @@ -194,8 +194,8 @@ sim_pop_data <- function( #' #' `sim.cs()` was renamed to [sim_pop_data()] to create a more #' consistent API. -#' #' @keywords internal +#' @export sim.cs <- function( n.smpl, age.rng, diff --git a/R/sim_pop_data_multi.R b/R/sim_pop_data_multi.R index ddb89eb29..2c1959486 100644 --- a/R/sim_pop_data_multi.R +++ b/R/sim_pop_data_multi.R @@ -121,6 +121,7 @@ sim_pop_data_multi <- function( #' to create a more consistent API. #' #' @keywords internal +#' @export sim.cs.multi <- function(...) { # nolint: object_name_linter lifecycle::deprecate_soft("1.3.1", "sim.cs.multi()", "sim_pop_data_multi()") sim_pop_data_multi(...) From 20c9b8792b6bed14ff0b50b345f9cef867ca7fdd Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Tue, 4 Feb 2025 17:54:30 -0800 Subject: [PATCH 2/5] Increment version number to 1.3.0.9020 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 35f574a18..10132c8af 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: serocalculator Title: Estimating Infection Rates from Serological Data -Version: 1.3.0.9019 +Version: 1.3.0.9020 Authors@R: c( person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"), comment = "Author of the method and original code."), From f51143174efca48cab907792acd152cc6bb1566f Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Tue, 4 Feb 2025 17:54:57 -0800 Subject: [PATCH 3/5] news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e1f7159b1..80c76d14e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,7 +25,7 @@ * Extended `simulate_xsectionalData.Rmd` article to explore `renew_params = TRUE` vs `renew_params = FALSE` (#348) -* Renamed variables for consistency (#281): +* Renamed variables for consistency (#281, #373): - `sim.cs()` -> `sim_pop_data()` - `sim.cs.multi()` -> `sim_pop_data_multi()` From 6cac85cf03f16662db6c31f9bfceba11b5ed08c1 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Wed, 5 Feb 2025 10:40:18 -0800 Subject: [PATCH 4/5] fix lint; ignore pdfs --- .gitignore | 1 + R/sim_pop_data.R | 41 +++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 729c5128b..8cc760f43 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ README_files NEWS.html NEWS_files **/.quarto/ +*.pdf diff --git a/R/sim_pop_data.R b/R/sim_pop_data.R index 9cd2e9314..255b0ac3a 100644 --- a/R/sim_pop_data.R +++ b/R/sim_pop_data.R @@ -93,7 +93,7 @@ sim_pop_data <- function( ...) { if (verbose > 1) { message("inputs to `sim_pop_data()`:") - print(environment() %>% as.list()) + print(environment() |> as.list()) } @@ -105,10 +105,10 @@ sim_pop_data <- function( # and provide `curve_params` instead. predpar <- - curve_params %>% - filter(.data$antigen_iso %in% antigen_isos) %>% - droplevels() %>% - prep_curve_params_for_array() %>% + curve_params |> + filter(.data$antigen_iso %in% antigen_isos) |> + droplevels() |> + prep_curve_params_for_array() |> df_to_array(dim_var_names = c("antigen_iso", "parameter")) stopifnot(length(lambda) == 1) @@ -116,7 +116,7 @@ sim_pop_data <- function( day2yr <- 365.25 lambda <- lambda / day2yr age_range <- age_range * day2yr - npar <- dimnames(predpar)$parameter %>% length() + npar <- dimnames(predpar)$parameter |> length() baseline_limits <- noise_limits @@ -149,8 +149,8 @@ sim_pop_data <- function( colnames(ysim) <- c("age", antigen_isos) to_return <- - ysim %>% - as_tibble() %>% + ysim |> + as_tibble() |> mutate( id = as.character(row_number()), age = round(.data$age / day2yr, 2) @@ -159,15 +159,15 @@ sim_pop_data <- function( if (format == "long") { if (verbose) message("outputting long format data") to_return <- - to_return %>% + to_return |> pivot_longer( cols = all_of(antigen_isos), values_to = c("value"), names_to = c("antigen_iso") - ) %>% + ) |> structure( format = "long" - ) %>% + ) |> as_pop_data( value = "value", age = "age", @@ -177,7 +177,7 @@ sim_pop_data <- function( } else { if (verbose) message("outputting wide format data") to_return <- - to_return %>% + to_return |> structure( class = c("pop_data_wide", class(to_return)), format = "wide" @@ -196,13 +196,13 @@ sim_pop_data <- function( #' consistent API. #' @keywords internal #' @export -sim.cs <- function( - n.smpl, - age.rng, - n.mc, - renew.params, - add.noise, - ...) { # nolint: object_name_linter +sim.cs <- function( # nolint: object_name_linter + n.smpl, # nolint: object_name_linter + age.rng, # nolint: object_name_linter + n.mc, # nolint: object_name_linter + renew.params, # nolint: object_name_linter + add.noise, # nolint: object_name_linter + ...) { # nolint: object_name_linter lifecycle::deprecate_soft("1.3.1", "sim.cs()", "sim_pop_data()") sim_pop_data( n_samples = n.smpl, @@ -210,5 +210,6 @@ sim.cs <- function( n_mcmc_samples = n.mc, renew_params = renew.params, add_noise = add.noise, - ...) + ... + ) } From 4360f07674ae81ab816c9a7479b3ab868b7872c0 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Wed, 5 Feb 2025 10:46:03 -0800 Subject: [PATCH 5/5] lint --- R/sim_pop_data_multi.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/sim_pop_data_multi.R b/R/sim_pop_data_multi.R index 2c1959486..4dc90cbf4 100644 --- a/R/sim_pop_data_multi.R +++ b/R/sim_pop_data_multi.R @@ -57,7 +57,7 @@ sim_pop_data_multi <- function( ...) { if (verbose) { message("inputs to `sim_pop_data_multi()`:") - print(environment() %>% as.list()) + print(environment() |> as.list()) } if (num_cores > 1L) { @@ -69,7 +69,7 @@ sim_pop_data_multi <- function( num_cores <- 2L } else { # use all cores in devtools::test() - num_cores <- num_cores %>% check_parallel_cores() + num_cores <- num_cores |> check_parallel_cores() } @@ -104,7 +104,7 @@ sim_pop_data_multi <- function( sim_pop_data( lambda = l, ... - ) %>% + ) |> mutate(lambda.sim = l, cluster = n) } doParallel::stopImplicitCluster()