Skip to content
Merged
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,6 +1,6 @@
Package: serodynamics
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9033
Version: 0.0.0.9034
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 NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## New features

* Replacing old data object with new run_mod output (#102)
* Adding class assignment to run_mod output (#76)
* Making prep_priors modifiable (#78)
* Changes to `run_mod()` output:
Expand Down
22 changes: 16 additions & 6 deletions R/nepal_sees_jags_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@
#' which is the diagnosis type (typhoid or
#' paratyphoid). Keeping only IDs `"newperson"`, `"sees_npl_1"`, `"sees_npl_2"`.
#'
#' @format ## `nepal_sees_jags_output`
#' A [list] consisting of the following named elements:
#' \describe{
#' \item{curve_params}{A [data.frame] titled `curve_params` that contains the
#' @format An S3 object of class `sr_model`: A [dplyr::tbl_df] that contains the
#' posterior predictive distribution of the person-specific parameters for a
#' "new person" with no observed data (`Subject = "newperson"`) and posterior
#' distributions of the person-specific parameters for two arbitrarily-chosen
#' subjects (`"sees_npl_1"` and `"sees_npl_2"`)}
#' \item{attributes}{A [list] of `attributes` that summarize the jags inputs}
#' subjects (`"sees_npl_1"` and `"sees_npl_2"`).
#' Contains 40,000 `rows`, 7 `columns`, and model `attributes`.
#' \describe{
#' \item{Iteration}{Number of sampling iterations: 500 iterations}
#' \item{Chain}{Number of MCMC chains run: 2 chains run}
#' \item{Parameter}{Parameter being estimated}
#' \item{Iso_type}{Antibody/antigen type combination being evaluated:
#' `HlyE_IgA` and `HlyE_IgG`}
#' \item{Stratification}{The variable used to stratify jags model: `typhi` and
#' `paratyphi`}
#' \item{Subject}{ID of subject being evaluated: `newperson`, `sees_npl_1`,
#' `sees_npl_2`}
#' \item{value}{Estimated value of the parameter}
#' \item{attributes}{A [list] of `attributes` that summarize the jags inputs,
#' priors, and optional jags_post mcmc object}
#' }
#' @source reference study: <https://doi.org/10.1016/S2666-5247(22)00114-8>
"nepal_sees_jags_output"
14 changes: 7 additions & 7 deletions R/plot_jags_densitydx.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#' @example inst/examples/examples-plot_jags_densitydx.R

plot_jags_dens <- function(data,
iso = unique(data$curve_params$Iso_type),
param = unique(data$curve_params$Parameter_sub),
strat = unique(data$curve_params$Stratification)) {
visualize_jags <- data[["curve_params"]]
iso = unique(data$Iso_type),
param = unique(data$Parameter),
strat = unique(data$Stratification)) {

attributes_jags <- data[["attributes"]]

dens_strat_list <- list()
for (i in strat) {

visualize_jags_sub <- visualize_jags |>
visualize_jags_sub <- data |>
dplyr::filter(.data$Stratification == i) |>
dplyr::filter(.data$Subject == "newperson")

Expand All @@ -55,12 +55,12 @@ plot_jags_dens <- function(data,
# Will not loop through parameters, as we may want each to show on the
# same plot by default.
visualize_jags_plot <- visualize_jags_plot |>
dplyr::filter(.data$Parameter_sub %in% param)
dplyr::filter(.data$Parameter %in% param)

visualize_jags_plot <- visualize_jags_plot |>
# Changing parameter name to reflect the input
dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
.data$Parameter_sub, ", strat = ",
.data$Parameter, ", strat = ",
i),
value = log(.data$value))
# Assigning attributes, which are needed to run ggs_density
Expand Down
14 changes: 7 additions & 7 deletions R/plot_jags_effectivedx.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@


plot_jags_effect <- function(data,
iso = unique(data$curve_params$Iso_type),
param = unique(data$curve_params$Parameter_sub),
strat = unique(data$curve_params$Stratification)) {
visualize_jags <- data[["curve_params"]]
iso = unique(data$Iso_type),
param = unique(data$Parameter),
strat = unique(data$Stratification)) {

attributes_jags <- data[["attributes"]]

eff_strat_list <- list()
for (i in strat) {

visualize_jags_sub <- visualize_jags |>
visualize_jags_sub <- data |>
dplyr::filter(.data$Stratification == i) |>
dplyr::filter(.data$Subject == "newperson")

Expand All @@ -59,11 +59,11 @@ plot_jags_effect <- function(data,
# Will not loop through parameters, as we may want each to show on the
# same plot by default.
visualize_jags_plot <- visualize_jags_plot |>
dplyr::filter(.data$Parameter_sub %in% param)
dplyr::filter(.data$Parameter %in% param)

visualize_jags_plot <- visualize_jags_plot |>
# Changing parameter name to reflect the input
dplyr::mutate(Parameter = .data$Parameter_sub)
dplyr::mutate(Parameter = .data$Parameter)
# Assigning attributes, which are needed to run ggs_density
attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
attributes_jags)
Expand Down
14 changes: 7 additions & 7 deletions R/plot_jags_rhatdx.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
#' @example inst/examples/examples-plot_jags_rhatdx.R

plot_jags_Rhat <- function(data, # nolint: object_name_linter
iso = unique(data$curve_params$Iso_type),
param = unique(data$curve_params$Parameter_sub),
strat = unique(data$curve_params$Stratification)) {
visualize_jags <- data[["curve_params"]]
iso = unique(data$Iso_type),
param = unique(data$Parameter),
strat = unique(data$Stratification)) {

attributes_jags <- data[["attributes"]]

rhat_strat_list <- list()
for (i in strat) {

visualize_jags_sub <- visualize_jags |>
visualize_jags_sub <- data |>
dplyr::filter(.data$Stratification == i) |>
dplyr::filter(.data$Subject == "newperson")

Expand All @@ -58,11 +58,11 @@ plot_jags_Rhat <- function(data, # nolint: object_name_linter
# Will not loop through parameters, as we may want each to show on the
# same plot by default.
visualize_jags_plot <- visualize_jags_plot |>
dplyr::filter(.data$Parameter_sub %in% param)
dplyr::filter(.data$Parameter %in% param)

visualize_jags_plot <- visualize_jags_plot |>
# Changing parameter name to reflect the input
dplyr::mutate(Parameter = .data$Parameter_sub,
dplyr::mutate(Parameter = .data$Parameter,
value = log(.data$value))
# Assigning attributes, which are needed to run ggs_rhat
attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
Expand Down
14 changes: 7 additions & 7 deletions R/plot_jags_tracedx.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#' @example inst/examples/examples-plot_jags_tracedx.R

plot_jags_trace <- function(data,
iso = unique(data$curve_params$Iso_type),
param = unique(data$curve_params$Parameter_sub),
strat = unique(data$curve_params$Stratification)) {
visualize_jags <- data[["curve_params"]]
iso = unique(data$Iso_type),
param = unique(data$Parameter),
strat = unique(data$Stratification)) {

attributes_jags <- data[["attributes"]]

trace_strat_list <- list()
for (i in strat) {

visualize_jags_sub <- visualize_jags |>
visualize_jags_sub <- data |>
dplyr::filter(.data$Stratification == i) |>
dplyr::filter(.data$Subject == "newperson")

Expand All @@ -55,12 +55,12 @@ plot_jags_trace <- function(data,
# Will not loop through parameters, as we may want each to show on the
# same plot by default.
visualize_jags_plot <- visualize_jags_plot |>
dplyr::filter(.data$Parameter_sub %in% param)
dplyr::filter(.data$Parameter %in% param)

visualize_jags_plot <- visualize_jags_plot |>
# Changing parameter name to reflect the input
dplyr::mutate(Parameter = paste0("iso = ", j, ", parameter = ",
.data$Parameter_sub, ", strat = ",
.data$Parameter, ", strat = ",
i))
# Assigning attributes, which are needed to run ggs_density
attributes(visualize_jags_plot) <- c(attributes(visualize_jags_plot),
Expand Down
13 changes: 6 additions & 7 deletions R/post_summ.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@
#' post_summ(data = serodynamics::nepal_sees_jags_output)

post_summ <- function(data,
iso = unique(data$curve_params$Iso_type),
param = unique(data$curve_params$Parameter_sub),
strat = unique(data$curve_params$Stratification)) {
summarize_jags <- data[["curve_params"]]
iso = unique(data$Iso_type),
param = unique(data$Parameter),
strat = unique(data$Stratification)) {

summarize_jags <- summarize_jags |>
summarize_jags <- data |>
filter(.data$Iso_type %in% iso) |>
filter(.data$Parameter_sub %in% param) |>
filter(.data$Parameter %in% param) |>
filter(.data$Stratification %in% strat) |>
dplyr::filter(.data$Subject == "newperson")

summarize_jags <- summarize_jags |>
dplyr::group_by(.data$Iso_type, .data$Parameter_sub,
dplyr::group_by(.data$Iso_type, .data$Parameter,
.data$Stratification) |>
dplyr::summarize(Mean = mean(.data$value),
SD = stats::sd(.data$value),
Expand Down
5 changes: 2 additions & 3 deletions data-raw/nepal_sees_jags_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ nepal_sees_jags_output <- run_mod(
nmc = 500,
niter = 1000, # Number of iterations
strat = "bldculres", # Stratification
with_post = FALSE,
include_subs = TRUE
with_post = FALSE
)

# Filtering to keep only 2 subjects + newperson
nepal_sees_jags_output$curve_params <- nepal_sees_jags_output$curve_params |>
nepal_sees_jags_output <- nepal_sees_jags_output |>
filter(Subject %in% c("newperson", "sees_npl_1", "sees_npl_2"))

usethis::use_data(nepal_sees_jags_output, overwrite = TRUE)
Binary file modified data/nepal_sees_jags_output.rda
Binary file not shown.
24 changes: 16 additions & 8 deletions man/nepal_sees_jags_output.Rd

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

6 changes: 3 additions & 3 deletions man/plot_jags_Rhat.Rd

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

6 changes: 3 additions & 3 deletions man/plot_jags_dens.Rd

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

6 changes: 3 additions & 3 deletions man/plot_jags_effect.Rd

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

6 changes: 3 additions & 3 deletions man/plot_jags_trace.Rd

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

6 changes: 3 additions & 3 deletions man/post_summ.Rd

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

44 changes: 22 additions & 22 deletions tests/testthat/_snaps/post_summ.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
results
Output
# A tibble: 20 x 11
Iso_type Parameter_sub Stratification Mean SD Median `2.5%` `25.0%`
<chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 HlyE_IgA alpha paratyphi 2.29e-3 3.75e-3 1.27e-3 1.11e-4 5.79e-4
2 HlyE_IgA alpha typhi 3.78e-3 6.16e-3 2.17e-3 3.08e-4 1.12e-3
3 HlyE_IgA shape paratyphi 1.66e+0 2.74e-1 1.61e+0 1.29e+0 1.47e+0
4 HlyE_IgA shape typhi 1.65e+0 3.68e-1 1.57e+0 1.23e+0 1.42e+0
5 HlyE_IgA t1 paratyphi 3.85e+0 1.34e+0 3.70e+0 1.86e+0 2.92e+0
6 HlyE_IgA t1 typhi 7.62e+0 4.83e+0 6.67e+0 2.26e+0 4.61e+0
7 HlyE_IgA y0 paratyphi 2.55e+0 9.07e-1 2.41e+0 1.23e+0 1.87e+0
8 HlyE_IgA y0 typhi 2.90e+0 2.92e+0 2.25e+0 5.76e-1 1.52e+0
9 HlyE_IgA y1 paratyphi 1.02e+3 6.84e+3 1.54e+2 8.85e+0 5.45e+1
10 HlyE_IgA y1 typhi 1.73e+3 7.50e+3 2.69e+2 8.41e+0 9.10e+1
11 HlyE_IgG alpha paratyphi 2.57e-3 2.60e-3 1.74e-3 2.29e-4 8.76e-4
12 HlyE_IgG alpha typhi 1.75e-3 1.69e-3 1.22e-3 2.38e-4 7.06e-4
13 HlyE_IgG shape paratyphi 1.36e+0 2.03e-1 1.32e+0 1.10e+0 1.19e+0
14 HlyE_IgG shape typhi 1.52e+0 3.88e-1 1.42e+0 1.11e+0 1.27e+0
15 HlyE_IgG t1 paratyphi 4.78e+0 2.09e+0 4.37e+0 1.93e+0 3.30e+0
16 HlyE_IgG t1 typhi 9.76e+0 8.02e+0 7.67e+0 1.87e+0 4.59e+0
17 HlyE_IgG y0 paratyphi 1.72e+0 7.66e-1 1.54e+0 7.09e-1 1.19e+0
18 HlyE_IgG y0 typhi 2.29e+0 1.94e+0 1.82e+0 3.80e-1 1.09e+0
19 HlyE_IgG y1 paratyphi 8.33e+2 2.13e+3 2.88e+2 1.82e+1 1.09e+2
20 HlyE_IgG y1 typhi 4.02e+2 6.91e+2 2.21e+2 3.02e+1 1.07e+2
Iso_type Parameter Stratification Mean SD Median `2.5%` `25.0%`
<chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 HlyE_IgA alpha paratyphi 0.00229 3.75e-3 1.27e-3 1.11e-4 5.79e-4
2 HlyE_IgA alpha typhi 0.00378 6.16e-3 2.17e-3 3.08e-4 1.12e-3
3 HlyE_IgA shape paratyphi 1.66 2.74e-1 1.61e+0 1.29e+0 1.47e+0
4 HlyE_IgA shape typhi 1.65 3.68e-1 1.57e+0 1.23e+0 1.42e+0
5 HlyE_IgA t1 paratyphi 3.85 1.34e+0 3.70e+0 1.86e+0 2.92e+0
6 HlyE_IgA t1 typhi 7.62 4.83e+0 6.67e+0 2.26e+0 4.61e+0
7 HlyE_IgA y0 paratyphi 2.55 9.07e-1 2.41e+0 1.23e+0 1.87e+0
8 HlyE_IgA y0 typhi 2.90 2.92e+0 2.25e+0 5.76e-1 1.52e+0
9 HlyE_IgA y1 paratyphi 1024. 6.84e+3 1.54e+2 8.85e+0 5.45e+1
10 HlyE_IgA y1 typhi 1726. 7.50e+3 2.69e+2 8.41e+0 9.10e+1
11 HlyE_IgG alpha paratyphi 0.00257 2.60e-3 1.74e-3 2.29e-4 8.76e-4
12 HlyE_IgG alpha typhi 0.00175 1.69e-3 1.22e-3 2.38e-4 7.06e-4
13 HlyE_IgG shape paratyphi 1.36 2.03e-1 1.32e+0 1.10e+0 1.19e+0
14 HlyE_IgG shape typhi 1.52 3.88e-1 1.42e+0 1.11e+0 1.27e+0
15 HlyE_IgG t1 paratyphi 4.78 2.09e+0 4.37e+0 1.93e+0 3.30e+0
16 HlyE_IgG t1 typhi 9.76 8.02e+0 7.67e+0 1.87e+0 4.59e+0
17 HlyE_IgG y0 paratyphi 1.72 7.66e-1 1.54e+0 7.09e-1 1.19e+0
18 HlyE_IgG y0 typhi 2.29 1.94e+0 1.82e+0 3.80e-1 1.09e+0
19 HlyE_IgG y1 paratyphi 833. 2.13e+3 2.88e+2 1.82e+1 1.09e+2
20 HlyE_IgG y1 typhi 402. 6.91e+2 2.21e+2 3.02e+1 1.07e+2
# i 3 more variables: `50.0%` <dbl>, `75.0%` <dbl>, `97.5%` <dbl>