Sample size em edits#369
Conversation
--author "Kwan Ho Lee" <ksjlee@ucdavis.edu>
Codecov Report✅ All modified and coverable lines are covered by tests. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new data-raw/ script to run parallelized seroincidence simulations for exploring sample-size behavior, and updates package metadata to include additional optional dependencies used by supporting workflows/scripts.
Changes:
- Add
data-raw/sample-size.Rto simulate cross-sectional serology data and summarize CI coverage across scenarios. - Add
furrrandsvglitetoSuggestsinDESCRIPTION(for optional parallel mapping and SVG-based visual regression testing support).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| DESCRIPTION | Adds optional dependencies (furrr, svglite) needed by scripts/testing tools. |
| data-raw/sample-size.R | New simulation + summarization script for evaluating sample size / CI coverage under different incidence rates. |
| est <- est.incidence( | ||
| pop_data = csdata, | ||
| curve_params = dmcmc, | ||
| noise_params = cond, | ||
| lambda_start = 0.1, | ||
| build_graph = FALSE, | ||
| verbose = FALSE, | ||
| print_graph = FALSE, | ||
| antigen_isos = antibodies | ||
| ) |
| ## Load longitudinal parameters | ||
|
|
||
| test_sim <- "https://osf.io/download/rtw5k" %>% | ||
| load_curve_params() %>% |
| csdata <- sim.cs( | ||
| curve_params = dmcmc, | ||
| lambda = lambda, | ||
| n.smpl = nrep, | ||
| age.rng = lifespan, | ||
| antigen_isos = antibodies, | ||
| n.mc = 0, | ||
| renew.params = TRUE, # Use different parameters for each simulation | ||
| add.noise = TRUE, | ||
| noise_limits = dlims, | ||
| format = "long" | ||
| ) |
| results_100 <- simulate_seroincidence(lambda = 0.2, nrep = 100, n_sim = 300) | ||
|
|
||
| results_100_0.1 <- simulate_seroincidence(lambda = 0.1, nrep = 100, n_sim = 300) | ||
|
|
||
| results_100_0.01 <- simulate_seroincidence(lambda = 0.1, nrep = 100, n_sim = 300) | ||
|
|
|
|
||
| results_100_0.1 <- simulate_seroincidence(lambda = 0.1, nrep = 100, n_sim = 300) | ||
|
|
||
| results_100_0.01 <- simulate_seroincidence(lambda = 0.1, nrep = 100, n_sim = 300) |
| final_table_50 <- results_50 |> generate_final_table(sample_size = 50) | ||
| final_table_100 <- results_100 |> generate_final_table(sample_size = 100) | ||
| final_table_100_0.1 <- results_100_0.1 |> generate_final_table(sample_size = 100) | ||
| ft_100_0.01 <- results_100_0.01 |> generate_final_table() | ||
| lambda <- function(results_table) |
|
Claude finished @d-morrison's task in 2m 38s —— View job Code Review
SummaryThis PR adds Critical Bug — Will Error at Runtime
Fix: replace the block with the current API: est <- est_seroincidence(
pop_data = csdata,
sr_params = dmcmc,
noise_params = cond,
lambda_start = 0.1,
build_graph = FALSE,
verbose = FALSE,
antigen_isos = antibodies
)CI Lint Failures — Will Block MergeLines 102, 104, 152, 153 — Object names containing
All downstream references to these names (lines 152, 153, 178–179) must be updated consistently. Logic Bug — Mislabeled ResultLine 104 — Reproducibility — Missing SeedsLines 102 and 104 — Deprecated API Calls — Will Emit Lifecycle WarningsAll three deprecated wrappers emit
Minor Issues
DESCRIPTION Changes
|
|
I'll analyze this and get back to you. |
- Replace deprecated load_curve_params/sim.cs/est.incidence with load_sr_params/sim_pop_data/est_seroincidence (and sr_params arg) - Rename objects with dots to snake_case (object_name_linter) - Fix mislabeled lambda=0.01 scenario and add per-call seeds - Use seq_along(); declare future in Suggests; move library(future) to top
|
Addressed the review findings in
This is an internal maintainer script in @claude review Generated by Claude Code |
|
Claude finished @d-morrison's task in 2m 16s —— View job Code Review
SummaryAll findings from the previous review have been addressed. The script is substantially improved. A few minor remaining items below — none are blocking for a Previous Findings — All Resolved ✅
Remaining Minor ItemsLine 77 — The previous fix changed furrr::future_map(.x = 1:n_sim, ...)Prefer Lines 179–180 — Coverage not printed
final_table_100_0_1 |> compute_coverage() # result discarded
ft_100_0_01 |> compute_coverage() # result discardedWhen run non-interactively (e.g. Lines 182–183 —
print(paste("Number of rows where CI covers true lambda:", coverage_count_50))will produce something like DESCRIPTION / WORDLIST
|
|
👀 Picked up by workflow run #26910326827. R setup runs first; Claude itself responds after that. |
|
📖 https://UCD-SERG.github.io/serocalculator/preview/pr369/ |
|
@claude review Generated by Claude Code |
|
👀 Picked up by workflow run #26911728637. R setup runs first; Claude itself responds after that. |

Thank you for taking the time to submit a pull request!
To maximize the chances of acceptance:
Fixes #issue-number(if relevant).-.testthat).For more information see Contributing.