Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
aea299a
Adding class sero_mod_output to run_mod output
sschildhauer Jun 25, 2025
a13db94
Specifying class in run_mod
sschildhauer Jun 25, 2025
eef3d8e
creating default print function method for sero_mod_output objects
sschildhauer Jun 25, 2025
147ae9e
Adding S3 method to NameSpace
sschildhauer Jun 25, 2025
ea74517
Documentation for default print method
sschildhauer Jun 25, 2025
4af5d36
Merging with main
sschildhauer Jul 9, 2025
102cb80
Creating default print for run_mod objects
sschildhauer Jul 9, 2025
7323fda
Creating a test for default run_mod object print
sschildhauer Jul 9, 2025
88b96af
Updating example for print default
sschildhauer Jul 9, 2025
91a887f
Updating documentation for default print
sschildhauer Jul 9, 2025
a7afd63
Arranging data by Iso_type to allow for easy comparison between strat…
sschildhauer Jul 9, 2025
f5be2b3
Adding test snap for run_mod object default print
sschildhauer Jul 9, 2025
ba5973f
Updating default sr_model print documentation
sschildhauer Jul 9, 2025
4ed27e6
Updating example for print.sr_model
sschildhauer Jul 9, 2025
8e5eba7
Increment version number to 0.0.0.9035
sschildhauer Jul 9, 2025
f377d5c
Updating news
sschildhauer Jul 9, 2025
9711df6
Adding print.sr_model to pkgdown
sschildhauer Jul 9, 2025
ff9ee85
Deleting a previous default print method that was being created
sschildhauer Jul 9, 2025
8eed4a7
Updating function for pivot_wider
sschildhauer Jul 9, 2025
7a5ec62
Updating documentation to take out old print function
sschildhauer Jul 9, 2025
eb4e282
Updating wordlist
sschildhauer Jul 10, 2025
141ba3c
Updating lint
sschildhauer Jul 10, 2025
f95a88a
Fixing no lint.
sschildhauer Jul 10, 2025
4dcd890
Updating test lint
sschildhauer Jul 14, 2025
ee0a73c
Changing review recommended test code
sschildhauer Jul 14, 2025
0dbc9a2
Updating test code based on review recommendations
sschildhauer Jul 14, 2025
a22ed27
Adding .data$ back in to code
sschildhauer Jul 14, 2025
29ec557
Update NEWS.md
sschildhauer Jul 16, 2025
9de64b0
Updating parameter inputs to refelct x, ...
sschildhauer Jul 17, 2025
b1d15c4
Fixing column call for taking out Stratification
sschildhauer Jul 17, 2025
0dcac18
Fixing column Stratification exclusion
sschildhauer Jul 17, 2025
86e9965
Changing object call in function to "x"
sschildhauer Jul 17, 2025
d97e4b2
Updating test for default print
sschildhauer Jul 17, 2025
3665740
Merge branch 'default_print' of https://github.com/UCD-SERG/serodynam…
sschildhauer Jul 17, 2025
afc12a7
Merging with main after plot_predicted_curve update
sschildhauer Jul 17, 2025
42b1810
Increment version number to 0.0.0.9036
sschildhauer Jul 17, 2025
5c9fe1c
Updating visible binding
sschildhauer Jul 17, 2025
1252e18
Merged origin/main into default_print
sschildhauer Jul 31, 2025
9a6931e
Updating output description and documentation
sschildhauer Jul 31, 2025
6dda0ca
Increment version number to 0.0.0.9037
sschildhauer Jul 31, 2025
d72bedc
Deleting snap
sschildhauer Jul 31, 2025
26c7800
Updating test and snapshot
sschildhauer Jul 31, 2025
27b1c52
Fixing lint in test
sschildhauer Aug 1, 2025
e6b54c1
Fixing for closure
sschildhauer Aug 1, 2025
1657ff1
Fixing data call in if statement
sschildhauer Aug 1, 2025
571bf16
Updating snap.
sschildhauer Aug 1, 2025
95a91c9
making output table a dataframe to get rid of tibble descriptors
sschildhauer Aug 3, 2025
3915ec2
Updating print test
sschildhauer Aug 4, 2025
4233b52
Updating snap
sschildhauer Aug 4, 2025
37f451e
Making model output median value
sschildhauer Aug 7, 2025
3f8c706
Updating test snap
sschildhauer Aug 7, 2025
afbb88a
Merge branch 'main' into default_print
sschildhauer Aug 7, 2025
ff21aa3
Increment version number to 0.0.0.9038
sschildhauer Aug 8, 2025
47ab5b0
Redoing snap
sschildhauer Aug 8, 2025
0c2a6bd
Updating snap to suppress warnings
sschildhauer Aug 8, 2025
04c7200
Updating snap
sschildhauer Aug 8, 2025
87dd5c7
troubleshooting snap
sschildhauer Aug 8, 2025
9f2fd61
Fixing lint
sschildhauer Aug 8, 2025
70c94c4
Merging with main
sschildhauer Sep 12, 2025
55c97aa
Merging with main
sschildhauer Sep 12, 2025
948b2e0
Merging with main
sschildhauer Oct 1, 2025
058ed61
Updating autoplot documentation
sschildhauer Oct 1, 2025
a24fc41
Updating plot_predictive_curve snaps
sschildhauer Oct 1, 2025
1b90556
Increment version number to 0.0.0.9043
sschildhauer Oct 1, 2025
2cad837
Changing the median function to try and fix the snap issue
sschildhauer Oct 1, 2025
97f2931
Updating plot_predicted curve snaps after ggplot update
sschildhauer Oct 2, 2025
f9a3f53
Updating autoplot documentation
sschildhauer Oct 2, 2025
597d613
Merged origin/main into default_print
sschildhauer Oct 8, 2025
3fc100c
Updating print snap
sschildhauer Oct 8, 2025
64d7ea4
Increment version number to 0.0.0.9044
sschildhauer Oct 9, 2025
2985fc6
Adding option to print output as tibble
sschildhauer Oct 9, 2025
46d53a3
Updating lint and structure of logical indicator
sschildhauer Oct 9, 2025
f0bf068
Updating tests for print
sschildhauer Oct 9, 2025
c25630c
Updadting snaps for default print to test a tbl output
sschildhauer Oct 9, 2025
4a14365
Fixing lint
sschildhauer Oct 9, 2025
89e5bf5
Updating stats::median call
sschildhauer Oct 9, 2025
a2be022
Merged origin/main into default_print
sschildhauer Oct 11, 2025
c9847dc
Updating print documentation
sschildhauer Oct 27, 2025
e160b39
Update R/print.sr_model.R
sschildhauer Oct 27, 2025
7fdb0d4
Updating lint for print
sschildhauer Oct 27, 2025
c6de84f
Merge branch 'main' into default_print
sschildhauer Oct 28, 2025
2eb9a29
Merged origin/main into default_print
sschildhauer Dec 24, 2025
91de966
Merging with main
sschildhauer Mar 30, 2026
dee362d
Increment version number to 0.0.0.9048
sschildhauer Mar 30, 2026
822b1e3
Updating expect snapshot
sschildhauer Mar 31, 2026
d411543
Note in expect_snapshot_data
sschildhauer Apr 8, 2026
9546eef
Adding a test for default print with no stratification
sschildhauer Apr 8, 2026
6f19b4e
filtering to newperson
sschildhauer Apr 8, 2026
deb74e8
Changing documentation and taking out ... as recommended by copilot
sschildhauer Apr 8, 2026
3ef9db1
Adding an invisibile command
sschildhauer Apr 8, 2026
a7ddcc0
Fixing lint
sschildhauer Apr 8, 2026
61b802d
Fixing title for default print test
sschildhauer Apr 8, 2026
76225d2
changing snap to darwin variant
sschildhauer Apr 8, 2026
0e52f43
Update R/print.sr_model.R
sschildhauer Apr 8, 2026
215e02b
Adding ... back in to allow for additional arguments
sschildhauer Apr 8, 2026
004d427
Merge branch 'default_print' of https://github.com/UCD-SERG/serodynam…
sschildhauer Apr 8, 2026
06d8d53
Clarifying in documentation that we are printing the predictive distr…
sschildhauer Apr 8, 2026
5d086af
Update tests/testthat/test-print.sr_model.R
sschildhauer Apr 8, 2026
8145cc9
Update tests/testthat/test-print.sr_model.R
sschildhauer Apr 8, 2026
60acbd4
Updating non-stratified results to be a snap of the print, not a tbl
sschildhauer Apr 8, 2026
129adce
Updating lint in test
sschildhauer Apr 8, 2026
ec7f1ed
Updating test snap
sschildhauer Apr 8, 2026
0be057f
Update R/print.sr_model.R
sschildhauer Apr 8, 2026
1a97278
Fix .data in tidyselect contexts, regenerate docs, add missing snapshot
Copilot Apr 8, 2026
ec88ab1
Fix dplyr::tbl_df reference to tibble::tbl_df in documentation
Copilot Apr 8, 2026
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,6 +1,6 @@
Package: serodynamics
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9047
Version: 0.0.0.9048
Authors@R: c(
person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"),
comment = "Author of the method and original code."),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(autoplot,case_data)
S3method(print,sr_model)
export(as_case_data)
export(autoplot)
export(expect_snapshot_data)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

## New features

* Creating default print.sr_model function for sr_model class (#114)
* Made "newperson" optional in `prep_data()` (#73)
Comment thread
sschildhauer marked this conversation as resolved.
* Including fitted and residual values as data frame in run_mod output. (#101)
* Added `plot_predicted_curve()` with support for faceting by multiple IDs (#68)
Expand Down
1 change: 1 addition & 0 deletions R/Run_Mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,5 @@ run_mod <- function(data,
jags_out <- jags_out |>
structure(class = union("sr_model", class(jags_out)))
jags_out

}
50 changes: 50 additions & 0 deletions R/print.sr_model.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#' @title Default print for [serodynamics::run_mod()] output object of class
#' `sr_model`
#' @description
#' A default print method for class `sr_model` that prints posterior medians
#' for antibody kinetic curve parameters by `Iso_type` and
#' `Stratification` (if specified).
#' @param x An `sr_model` output object from [run_mod()].
#' @param print_tbl A [logical] indicator to print `x` in the style of a
#' [tibble::tbl_df].
#' @param ... Additional arguments passed to the print method.
#' @returns Invisibly returns either:
#' \itemize{
#' \item when `print_tbl = TRUE`, a tibble containing the raw `sr_model`
#' draws;
#' \item otherwise, a data summary containing posterior medians for
#' antibody kinetic curve parameters by `Iso_type` and `Stratification`
#' (if specified).
#' }
Comment thread
sschildhauer marked this conversation as resolved.
#' @export
#' @examples
#' print(nepal_sees_jags_output)
print.sr_model <- function(x,
print_tbl = FALSE,
...) { # nolint
if (print_tbl) {
x <- dplyr::as_tibble(x)
print(x)
invisible(x)
Comment thread
sschildhauer marked this conversation as resolved.
Comment on lines +22 to +28
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ... argument is accepted but not used. In S3 print methods, ... should typically be forwarded to the underlying print() call (e.g., to control digits, n, width, etc.); otherwise remove ... from the signature/docs.

Copilot uses AI. Check for mistakes.
} else {
Comment thread
sschildhauer marked this conversation as resolved.
cat("An sr_model with the following median values:")
cat("\n")
cat("\n")
x <- suppressWarnings({
x |>
dplyr::filter(.data$Subject == "newperson") |>
dplyr::summarise(.by = c("Stratification", "Iso_type", "Parameter"),
median_val = stats::median(.data$value)) |>
tidyr::pivot_wider(names_from = "Parameter",
values_from = "median_val") |>
dplyr::arrange(.data$Iso_type)
})
# Taking out stratification column if not specified
if (!"Stratification" %in% names(x) || all(x$Stratification == "None",
na.rm = TRUE)) {
x <- dplyr::select(x, -dplyr::any_of("Stratification"))
}
print(as.data.frame(x))
invisible(x)
}
}
4 changes: 4 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ mcmc
mitre
newperson
nmc
npl
overfit
otimes
onwards
params
pkgdown
Expand All @@ -48,6 +51,7 @@ rhat
seroconversion
seroresponse
seroresponses
sr
strat
stratifications
tbl
Expand Down
2 changes: 1 addition & 1 deletion man/nepal_sees_jags_output.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_predicted_curve.Rd

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

35 changes: 35 additions & 0 deletions man/print.sr_model.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/run_mod.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/use_att_names.Rd

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

1 change: 1 addition & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ reference:
- title: Summarize seroresponse model estimates
contents:
- post_summ
- print.sr_model
- title: Example data sets
contents:
- serodynamics_example
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/_snaps/darwin/print.sr_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# results consistent with printed output for sr_model as tbl no strat

Code
print(results)
Output
An sr_model with the following median values:

Iso_type alpha shape t1 y0 y1
1 HlyE_IgA 0.01637070 1.352345 2.74673 2.68448 968.6465
2 HlyE_IgG 0.00938515 1.288250 2.97289 2.61949 1099.8900

44 changes: 44 additions & 0 deletions tests/testthat/_snaps/print.sr_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# results are consistent with printed output for sr_model class

Code
nepal_sees_jags_output
Output
An sr_model with the following median values:

Stratification Iso_type alpha shape t1 y0 y1
1 typhi HlyE_IgA 0.001508265 1.673340 6.358405 2.340330 258.1235
2 paratyphi HlyE_IgA 0.001556295 1.561960 3.903690 2.852925 191.8805
3 typhi HlyE_IgG 0.001393980 1.385280 6.019110 1.788035 243.9110
4 paratyphi HlyE_IgG 0.001432405 1.386685 4.726980 2.330555 272.8455

# results are consistent with printed output for sr_model class as tbl

Code
print(nepal_sees_jags_output, print_tbl = TRUE)
Output
# A tibble: 70,000 x 7
Iteration Chain Parameter Iso_type Stratification Subject value
<int> <int> <chr> <chr> <chr> <chr> <dbl>
1 1 1 alpha HlyE_IgA typhi sees_npl_1 0.00757
2 2 1 alpha HlyE_IgA typhi sees_npl_1 0.00794
3 3 1 alpha HlyE_IgA typhi sees_npl_1 0.00794
4 4 1 alpha HlyE_IgA typhi sees_npl_1 0.0103
5 5 1 alpha HlyE_IgA typhi sees_npl_1 0.00925
6 6 1 alpha HlyE_IgA typhi sees_npl_1 0.00925
7 7 1 alpha HlyE_IgA typhi sees_npl_1 0.00950
8 8 1 alpha HlyE_IgA typhi sees_npl_1 0.00950
9 9 1 alpha HlyE_IgA typhi sees_npl_1 0.00852
10 10 1 alpha HlyE_IgA typhi sees_npl_1 0.00852
# i 69,990 more rows

# results consistent with printed output for sr_model as tbl no strat

Code
print(results)
Output
An sr_model with the following median values:

Iso_type alpha shape t1 y0 y1
1 HlyE_IgA 0.01718040 1.368230 2.755075 2.646905 1184.585
2 HlyE_IgG 0.01005685 1.293325 2.910905 2.641075 817.486

36 changes: 36 additions & 0 deletions tests/testthat/test-print.sr_model.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
test_that(
desc = "results are consistent with printed output for sr_model class",
code = {
testthat::expect_snapshot(nepal_sees_jags_output)
}
)

test_that(
desc = "results are consistent with printed output for sr_model class as tbl",
code = {
testthat::expect_snapshot(print(nepal_sees_jags_output, print_tbl = TRUE))
}
)
Comment thread
sschildhauer marked this conversation as resolved.

test_that(
desc = "results consistent with printed output for sr_model as tbl no strat",
code = {
withr::local_seed(1)
dataset <- serodynamics::nepal_sees
results <- run_mod(
data = dataset, # The data set input
file_mod = serodynamics_example("model.jags"),
nchain = 2, # Number of mcmc chains to run
nadapt = 10, # Number of adaptations to run
nburn = 10, # Number of unrecorded samples before sampling begins
nmc = 100,
niter = 100 # Number of iterations
) |>
Comment thread
sschildhauer marked this conversation as resolved.
suppressWarnings()
Comment thread
sschildhauer marked this conversation as resolved.

testthat::expect_snapshot(
print(results),
variant = darwin_variant()
)
}
Comment thread
sschildhauer marked this conversation as resolved.
)