Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 215: Merge main to spatial #224

Merged
merged 52 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9e39623
Adding class and methods for wwinference model fit (#58)
gvegayon Aug 30, 2024
257587b
Addressing R CMD check notes due to tidyeval syntax (#108)
gvegayon Sep 3, 2024
3a26b38
update hierarchical estimate of sigma_site in `model_definition` (#120)
kaitejohnson Sep 3, 2024
03c9030
Vignette tweaks (#141)
kaitejohnson Sep 4, 2024
4dc56d5
actually set seed
kaitejohnson Sep 5, 2024
80ea140
Set seeds in test_get_stan_data (#146)
dylanhmorris Sep 5, 2024
e7d2b9a
Modify package to expect log scale concentration values and LODs (#122)
kaitejohnson Sep 5, 2024
6df32c5
Tweaks to model definition (#134)
kaitejohnson Sep 6, 2024
6aed488
Fix check for required wastewater columns (#127)
kaitejohnson Sep 6, 2024
978c951
Switch to placing prior on and inferring `i/n` at the first observed …
dylanhmorris Sep 6, 2024
b3acddb
update vignette to reflect default NULL seed in mcmcoptions (#125)
kaitejohnson Sep 6, 2024
ca8e785
Fix NEWS.md (#126)
kaitejohnson Sep 9, 2024
494ea88
Update DESCRIPTION (#156)
kaitejohnson Sep 10, 2024
bd05d1a
Adding new class and method for get_draws (#153)
gvegayon Sep 12, 2024
50120bf
Add contributors (#160)
kaitejohnson Sep 12, 2024
40a9182
163 expand R version (#164)
kaitejohnson Sep 13, 2024
83a4202
Add hex logo to repo (#148)
kaitejohnson Sep 14, 2024
7a615c8
Various bug fixes (#128)
kaitejohnson Sep 16, 2024
fa2ba17
fix rendering to katex, add mathcal Rt to vignette (#169)
kaitejohnson Sep 17, 2024
65c3588
Tweaks to main vignette (#170)
kaitejohnson Sep 17, 2024
9b0937b
Adding the post-page-artifact job (#181)
gvegayon Sep 23, 2024
0137a96
Build link comment in PRs: update comment instead of re-creating on r…
dylanhmorris Sep 24, 2024
745dfe0
Only run post-page-artifact job on PRs (#183)
dylanhmorris Sep 24, 2024
bd3bb65
Fix formatting so functions link (#179)
kaitejohnson Sep 26, 2024
b0287ab
174 cmdstanr sample args (#175)
kaitejohnson Sep 27, 2024
46e896b
Hot fix validate pmf (#191)
kaitejohnson Sep 28, 2024
d35647e
Restructure hierarchical estimation based on reference subpopulation …
kaitejohnson Sep 30, 2024
1a60036
init had wrong name... (#199)
kaitejohnson Oct 1, 2024
452c9f7
add multiple os to matrix strategy (#190)
kaitejohnson Oct 2, 2024
5a52e59
Update NEWS.md (#205)
kaitejohnson Oct 2, 2024
d6d3192
Update README.md (#207)
kaitejohnson Oct 2, 2024
bf2ce80
Update DESCRIPTION (#203)
kaitejohnson Oct 2, 2024
49b6c0f
Fix error messaging when data extends beyond forecast date (#208)
kaitejohnson Oct 2, 2024
9dd766b
Positive constrain mode_sigma_ww_site (#210)
dylanhmorris Oct 4, 2024
7ea4e33
temporary fix for merge conflicts
kaitejohnson Oct 18, 2024
8363467
fix typo in resolving git conflicts
kaitejohnson Oct 19, 2024
e959481
change to local filepath to stan model for troubleshooting
kaitejohnson Oct 19, 2024
9935c43
model compiles
kaitejohnson Oct 19, 2024
cf625e4
modify the non spatial component slightly
kaitejohnson Oct 19, 2024
a25e1c5
troubleshooting simulateedd ata fxn
kaitejohnson Oct 19, 2024
356e336
add package data for both vignettes
kaitejohnson Oct 25, 2024
4822fa0
fix handling of subpops from merge, modify vignette temporarily
kaitejohnson Oct 25, 2024
4d5ad81
WIP thinking through changes to spatial model with new structure
kaitejohnson Oct 25, 2024
6b7d824
get something to work for no hosp model with n subpops = 1
kaitejohnson Oct 25, 2024
c1f8400
add spatial model components to get stan data tests
kaitejohnson Oct 26, 2024
4d48539
fix vignette, remove here
kaitejohnson Oct 26, 2024
6cb6447
update with new get draws df
kaitejohnson Oct 28, 2024
0fea1c7
fix bug in samplign draws
kaitejohnson Oct 30, 2024
ffb81e4
fix to remove any get_draws_df
kaitejohnson Oct 30, 2024
588d02b
fix to remove any get_draws_df
kaitejohnson Oct 30, 2024
8f5ab90
fix hosp plots
kaitejohnson Oct 30, 2024
9d14468
fix all the dependencies from changing get_draws_df to get_draws
kaitejohnson Oct 31, 2024
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
33 changes: 33 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
contents: write
id-token: write
pages: write
outputs:
page_artifact_id: ${{ steps.upload-artifact.outputs.artifact_id }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -52,6 +54,7 @@ jobs:
shell: Rscript {0}

- name: Upload artifact for GH pages deployment
id: upload-artifact
uses: actions/upload-pages-artifact@v3
with:
path: "docs/"
Expand All @@ -72,3 +75,33 @@ jobs:
steps:
- name: Deploy to GitHub pages
uses: actions/deploy-pages@v4

post-page-artifact:
# only comment on PRs
if: ${{ github.event_name == 'pull_request' }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Your page is ready to preview

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Thank you for your contribution, @${{ github.triggering_actor }} :rocket:! Your page is ready to preview [here](https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}/artifacts/${{ needs.build.outputs.page_artifact_id }})
edit-mode: replace
10 changes: 7 additions & 3 deletions .github/workflows/r-cmd-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ on:

jobs:
check-package:
runs-on: ubuntu-latest
strategy:
matrix:
r-version: ["4.1.0", "release"]
os: [windows-latest, ubuntu-latest]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
r-version: ${{matrix.r-version}}
use-public-rspm: true
extra-repositories: "https://mc-stan.org/r-packages/"
- name: "Set up dependencies for wwinference"
Expand All @@ -24,6 +27,7 @@ jobs:
uses: epinowcast/actions/install-cmdstan@v1
with:
cmdstan-version: "latest"
num-cores: 2
- name: "Check wwinference package"
uses: r-lib/actions/check-r-package@v2
with:
Expand Down
26 changes: 22 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wwinference
Title: Jointly infers infection dynamics from wastewater data and epidemiological indicators
Version: 0.0.0.9000
Version: 0.1.0
Authors@R: c(
person(given = "Kaitlyn",
family = "Johnson",
Expand All @@ -23,7 +23,7 @@ Authors@R: c(
email = "[email protected]"),
person(given = "George",
family = "Vega Yon",
role = c("ctb"),
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-3171-0844")),
person(given = "Damon",
Expand All @@ -37,7 +37,25 @@ Authors@R: c(
person(given = "Scott",
family = "Olesen",
role = c("aut"),
email = "[email protected]")
email = "[email protected]"),
person(given = "Adam",
family = "Howes",
role = c("ctb"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-2386-4031")),
person(given = "Chirag",
family = "Kumar",
role = c("ctb"),
email = "[email protected]"),
person(given = "Alexander",
family = "Keyel",
role = c("ctb"),
email = "[email protected]",
comment = c(ORCID = "000-0001-5256-6274")),
person(given = "Hannah",
family = "Cohen",
role = c("ctb"),
email = "[email protected]")
)
Description: An implementation of a hierarchical semi-mechanistic renewal
approach jointly calibrating to multiple wastewater concentrations datasets from
Expand All @@ -54,7 +72,7 @@ License: Apache License (>= 2)
URL: https://github.com/cdcgov/ww-inference-model/, https://cdcgov.github.io/ww-inference-model/
BugReports: https://github.com/cdcgov/ww-inference-model/issues/
Depends:
R (>= 4.3.0)
R (>= 4.1.0)
SystemRequirements: CmdStan (>=2.35.0)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
18 changes: 12 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Generated by roxygen2: do not edit by hand

S3method(get_draws_df,data.frame)
S3method(get_draws_df,default)
S3method(get_draws_df,wwinference_fit)
S3method(get_draws,data.frame)
S3method(get_draws,default)
S3method(get_draws,wwinference_fit)
S3method(get_model_diagnostic_flags,default)
S3method(get_model_diagnostic_flags,wwinference_fit)
S3method(plot,wwinference_fit_draws)
S3method(print,wwinference_fit)
S3method(print,wwinference_fit_draws)
S3method(summary,wwinference_fit)
export(add_pmfs)
export(add_time_indexing)
Expand All @@ -20,10 +22,14 @@ export(generate_simulated_data)
export(get_count_data_sizes)
export(get_count_indices)
export(get_count_values)
export(get_date_time_spine)
export(get_draws)
export(get_draws_df)
export(get_ind_m)
export(get_input_count_data_for_stan)
export(get_input_ww_data_for_stan)
export(get_lab_site_site_spine)
export(get_lab_site_subpop_spine)
export(get_mcmc_options)
export(get_model_diagnostic_flags)
export(get_model_spec)
Expand All @@ -32,18 +38,18 @@ export(get_plot_forecasted_counts)
export(get_plot_global_rt)
export(get_plot_subpop_rt)
export(get_plot_ww_conc)
export(get_site_subpop_spine)
export(get_stan_data)
export(get_subpop_data)
export(get_ww_data_indices)
export(get_ww_data_sizes)
export(get_ww_values)
export(get_ww_indices_and_values)
export(independence_corr_func_r)
export(indicate_ww_exclusions)
export(parameter_diagnostics)
export(preprocess_count_data)
export(preprocess_ww_data)
export(rand_corr_matrix_func)
export(spatial_rt_process)
export(summary_diagnostics)
export(to_simplex)
export(validate_paramlist)
export(wwinference)
Expand Down
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# wwinference 0.0.1 (dev)

# wwinference 0.1.0

This is the first major release, focused on providing an initial version of the package.
Note the package is still flagged as in development, though the authors plan on using it for production work in the coming weeks.
Expand Down
89 changes: 69 additions & 20 deletions R/checkers.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@
#' @param date_vector vector of dates
#' @param max_date string indicating the maximum date in ISO8601 convention
#' e.g. YYYY-MM-DD
#' @param arg_dates string to print the name of the data you are checking the
#' dates for
#' @param arg_max_date string to print the name of the maximum date you are
#' checkign the data for
#' @param call Calling environment to be passed to [cli::cli_abort()] for
#' traceback.
#'
#' @return NULL, invisibly
assert_no_dates_after_max <- function(date_vector,
max_date, call = rlang::caller_env()) {
max_date,
arg_dates = "y",
arg_max_date = "x",
call = rlang::caller_env()) {
if (max(date_vector) > max_date) {
cli::cli_abort(
c(
"The data passed in has observations beyond the specified",
"maximum date. Either this is the incorrect vintaged",
"data, or the data needs to be filtered to only contain",
"observations before the maximum date"
"The {.arg_dates {arg_dates}} passed in has observations after the ",
"specified {.arg_max_date {arg_max_date}}. Check that this is the ",
"dataset you intended to use with the given ",
"{.arg_max_date {arg_max_date}}."
),
call = call,
class = "wwinference_input_data_error"
Expand Down Expand Up @@ -211,6 +218,46 @@ assert_no_repeated_elements <- function(x, arg = "x",
invisible()
}

#' Check a set of columns in a data frame uniquely identify
#' data frame rows.
#'
#' @description
#' Equivalently, this checks that when grouping by the columns in question,
#' each group has a single entry
#'
#' @param df the dataframe to check
#' @param unique_key_columns Columns that, taken together, should
#' uniquely identify a row in the data frame.
#' @param arg the name of the unique grouping to check
#' @param call Calling environment to be passed to [cli::cli_abort()] for
#' traceback.
#' @param add_err_msg string containing an additional error message,
#' default is the empty string (`""`)
#'
#' @return NULL, invisibly
assert_cols_det_unique_row <- function(df,
unique_key_columns,
arg = "x",
call = rlang::caller_env(),
add_err_msg = "") {
duplicated_rows <- df |> dplyr::filter(dplyr::n() > 1,
.by = {{ unique_key_columns }}
)

if (nrow(duplicated_rows) != 0) {
cli::cli_abort(
c("The data has more than one observation per {.arg {arg}}",
add_err_msg,
"i" = "Multiple observations in a {.arg {arg}} are not",
"currently supported."
),
call = call,
class = "wwinference_input_data_error"
)
}
invisible()
}



#' Assert that a vector is either of a vector of integers or a vector of
Expand Down Expand Up @@ -347,19 +394,15 @@ assert_req_ww_cols_present <- function(ww_data,
#' traceback.
#'
#' @return NULL, invisibly
check_req_count_cols_present <- function(count_data,
count_col_name,
pop_size_col_name,
add_req_col_names = c("date"),
call = rlang::caller_env()) {
assert_req_count_cols_present <- function(count_data,
count_col_name,
pop_size_col_name,
add_req_col_names = c("date"),
call = rlang::caller_env()) {
column_names <- colnames(count_data)
expected_col_names <- c(
{
count_col_name
},
{
pop_size_col_name
},
count_col_name,
pop_size_col_name,
add_req_col_names
)

Expand Down Expand Up @@ -491,6 +534,9 @@ assert_daily_data <- function(dates,
#' calibration time
#'
#' @param date_vector the vector of dates to check, must be of Date type
#' @param data_name What data correspond to the dates in `date_vector`.
#' Used to make the error message informative (e.g.
#' "hospital admissions data")
#' @param calibration_time integer indicating the number of days that
#' the dates must span
#' @param call Calling environment to be passed to [cli::cli_abort()] for
Expand All @@ -500,6 +546,7 @@ assert_daily_data <- function(dates,
#'
#' @return NULL invisible
assert_sufficient_days_of_data <- function(date_vector,
data_name,
calibration_time,
call = rlang::caller_env(),
add_err_msg = "") {
Expand All @@ -511,7 +558,8 @@ assert_sufficient_days_of_data <- function(date_vector,
if (!check_sufficient_data) {
cli::cli_abort(
c(
"Insufficient data for specified calibration time"
"Insufficient {.arg {data_name}} for the specified calibration time. ",
add_err_msg
),
call = call,
class = "wwinference_specification_error"
Expand Down Expand Up @@ -540,9 +588,8 @@ assert_dates_within_frame <- function(dates1,
checkmate::assert_date(dates1)
checkmate::assert_date(dates2)
check_dates2_win_frame <- min(dates1) <= max(dates2) &
min(dates2) >= min(dates1) &
max(dates2) <= max_date &
max(dates1) <= max_date
min(dates2) <= max(dates1)

if (!check_dates2_win_frame) {
cli::cli_abort(
c(
Expand All @@ -556,6 +603,8 @@ assert_dates_within_frame <- function(dates1,

invisible()
}


#' Assert that two tibbles of date and time mapping align
#'
#' @param first_data a tibble containing the columns `date` (with IS08601
Expand Down
Loading
Loading