Reorganize repo into package-ready structure with pkgdown + mock data + tests#11
Reorganize repo into package-ready structure with pkgdown + mock data + tests#11Kwan-Jenny merged 30 commits intomainfrom
Conversation
This function filters and reshapes longitudinal Shigella data for serodynamics workflows, standardizing column names and preparing the dataset for conversion.
This function summarizes population-level antibody trajectories for a hypothetical new individual, computing median and credible intervals. It allows customization of various parameters for plotting and data return options.
This function generates posterior predictions of antibody trajectories at specified time points for selected subjects and antigen/isotype. It processes posterior draws and evaluates the antibody curve using specified parameters.
This function computes residuals between observed antibody measurements and posterior median predictions, returning pointwise residuals or aggregated error metrics (MAE, RMSE, SSE) at various summary levels.
This function computes and compares residual metrics for serotype-specific and overall models, providing insights on their performance differences.
This function processes posterior draws for the 'newperson' subject, filtering and reshaping the data into a wide format suitable for analysis.
Codecov Report❌ Patch coverage is
|
There was a problem hiding this comment.
Pull request overview
This PR reorganizes the repository into a package-ready R structure by removing obsolete function files and adding new, well-documented functions with proper roxygen documentation. The changes focus on refactoring the R/ directory to support longitudinal antibody data analysis workflows.
Changes:
- Removed 8 obsolete function files (simulation helpers, cross-sectional data functions, JAGS postprocessing, plotting utilities)
- Added 6 new documented functions for longitudinal data processing, residual-based model diagnostics, parameter extraction, and visualization
- Improved code style with native pipe operator, explicit namespace calls, and
.datapronoun for non-standard evaluation
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| R/simulate_seroincidence.R | Deleted simulation function (no longer needed) |
| R/process_shigella_data.R | Refactored data reshaping function with roxygen docs and modern syntax |
| R/prepare_df_for_serocalculator.R | Deleted cross-sectional data preparation function |
| R/prep_newperson_params.R | New function to extract population-level parameter draws |
| R/predict_posterior_at_times.R | New internal helper for posterior predictions at specified times |
| R/postprocess_jags_output.R | Deleted JAGS output processing function |
| R/plot_summary_metrics.R | Deleted summary metrics plotting function |
| R/model_comparison_table.R | New function to compare models using residual metrics |
| R/generate_final_table.R | Deleted table generation function |
| R/fmt_mci.R | New utility to format median and credible intervals |
| R/fig2_overall_newperson.R | New function to visualize population-level antibody trajectories |
| R/create_xs_data.R | Deleted cross-sectional data creation function |
| R/create_noise_df.R | Deleted noise parameter dataframe function |
| R/create_incidence_table.R | Deleted incidence table creation function |
| R/compute_residual_metrics.R | New comprehensive function for residual-based posterior predictive checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@Kwan-Jenny I've opened a new pull request, #12, to work on those changes. Once the pull request is ready, I'll request review from you. |
…re (#12) * Initial plan * Fix DESCRIPTION dependencies and remove ::: usage - Move tibble, tidyr, purrr from Suggests to Imports - Add serocalculator and rlang to Imports - Remove unused cohort_name selection in process_shigella_data - Replace serodynamics::: calls with internal helper functions - Add utils_internal.R with get_timeindays_var() and ab() implementations Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Add package infrastructure: tests, workflows, vignettes, and mock data - Add testthat tests for main functions - Add R CMD check and pkgdown GitHub Actions workflows - Add data-raw/ with mock data generation script - Add R/data.R with mock data documentation - Add getting-started vignette - Update README.Rmd with package overview and usage - Update .Rbuildignore to exclude non-package files Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Fix rlang::rnorm() to rnorm() in mock data generation Use base R rnorm() instead of non-existent rlang::rnorm() Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Add permissions block to R-CMD-check workflow Set explicit GITHUB_TOKEN permissions (contents: read) for security Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Update documentation to remove reference to serodynamics:::ab() Update comment to reflect internal implementation instead of external ::: call Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Align internal utils with serodynamics and update tests Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/d36469e9-e5db-41bb-ad8f-cc452230b453 * Fix namespace export errors and add mock data .rda files Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/1327221c-702c-4c06-907f-1b381d75ecd9 Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Fix failing tests by adding model_comparison_table export and sync roxygen note Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/47d8cc5c-e58f-4f67-a13f-b5f56651a62e Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Fix remaining docs-check and lint CI issues Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/d635bda4-41b7-4feb-8fc3-330a60fec1ac Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> * Fix compute_residual_metrics indentation at line 137 Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/6af850e8-229a-4ffd-a552-ff9467c5bbbb Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
|
@copilot Now PR #11 (manuscript → main) has 5 failing CI checks. Please fix all of them: 1. Version increment check (CRITICAL — do this first)PR branch version ( Fix: In 2. R-CMD-check: 3 WARNINGsA. Invalid license file pointers: LICENSEDESCRIPTION references a LICENSE file that doesn't exist. Fix: Either:
B. Non-ASCII characters in
|
| # | Action | File(s) |
|---|---|---|
| 1 | Bump version to 0.0.0.9005 |
DESCRIPTION |
| 2 | Create LICENSE file | LICENSE |
| 3 | Fix non-ASCII characters | R/fmt_mci.R |
| 4 | Add VignetteBuilder + knitr/rmarkdown to Suggests | DESCRIPTION |
| 5 | Fix vignette header | vignettes/getting-started.Rmd |
| 6 | Move future, future.apply, gridExtra, serodynamics to Suggests | DESCRIPTION |
| 7 | Create/update inst/WORDLIST | inst/WORDLIST |
| 8 | Break long lines (≤80 chars) | R/fmt_mci.R, R/prep_newperson_params.R |
| 9 | Run devtools::document() and commit updated NAMESPACE |
NAMESPACE |
After all changes, please run devtools::document() to keep NAMESPACE in sync.
|
Please address the review comments as follows:
After fixes, run |
…n tests, TODO comment Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/a030fe7b-7a02-4d32-a346-01e663e62bad Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
All changes made in commit
|
|
The 1. Replace
|
…test Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/40bd4f82-f569-4387-98be-3bfec61029b2 Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Done in commit |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 47 out of 50 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/9c7dfb28-b082-4292-98b7-37fbefb0b36b Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/be13d809-cfdc-485c-889c-92a9d2ebd9c2 Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
|
|
Agent-Logs-Url: https://github.com/UCD-SERG/shigella/sessions/9263f1b7-8152-4f90-9f85-e2bb428c4798 Co-authored-by: Kwan-Jenny <68584166+Kwan-Jenny@users.noreply.github.com>
Fixed in commit |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 48 out of 51 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
These are all valid suggestions. Defensive checks and additional test coverage for exported functions (fmt_mci, prep_newperson_params, fig2_overall_newperson, make_model_comparison_table) will be addressed in a follow-up issue after this infrastructure PR is merged. |




Goal
Reorganize this repository into a package-ready R structure consistent with UCD-SERG repos (e.g., serocalculator), including:
R CMD check)This PR should include the existing function files already created on this branch and integrate them into a clean package layout.
What to include in this PR
1) Standard R package structure
Create/confirm these top-level files and directories (package-root layout):
DESCRIPTION(package metadata)NAMESPACE(generated via roxygen2)R/(already contains the functions from this branch)man/(roxygen output)tests/+tests/testthat/vignettes/(minimal vignette scaffold)data/(will store.rdaobjects)data-raw/(scripts that generatedata/*.rda).Rbuildignore,.gitignoreREADME.md(package + website badges, basic usage)2) pkgdown + GitHub Pages setup
Add pkgdown configuration consistent with UCD-SERG patterns:
_pkgdown.yml(site config, navbar, reference index)maingh-pagesdocs/or gh-pages (follow serocalculator style)3) R CMD check CI
Add GitHub Actions workflow for
R CMD checkon:mainUse r-lib/actions best practices (cache packages, matrix with OS if desired).
4) Mock data scaffold (no real Shigella data in this PR)
Because real Shigella
.rdaand the Excel dataset cannot be committed here:data/folder and commit small mock.rdaobjects needed to run examples/tests.data-raw/script that generates mock objects and saves them intodata/.serodynamics::as_case_data()(id, antigen_iso, time in days, values).rdawill be uploaded later intodata/.5) Minimal tests + examples using mock data
Add minimal testthat coverage using mock data only:
set.seed()inside mock-data generation.6) Documentation consistency
Ensure roxygen documentation exists for exported functions and that
devtools::document()producesman/*.Rd.Export policy:
Function files included
This branch already has function files under
R/(e.g., predict_posterior_at_times, compute_residual_metrics, model comparison, newperson parameter prep, etc.). Keep these and ensure they are:Acceptance criteria
R CMD checkpasses locally and in CINotes
Real Shigella data +
.rdaobjects will be added later todata/(or kept external if not shareable). This PR focuses on the infrastructure and package readiness while keeping CI green.