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

Port over the existing tests and set up CI #11

Merged
merged 108 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
6491e64
remove extra files
kaitejohnson Jun 26, 2024
342701a
add a .gitignore with R and data stuff
kaitejohnson Jun 26, 2024
4685a13
add git ignore from cfa-repo-template
kaitejohnson Jun 26, 2024
f66494a
make .github folder mirror cfa-repo-template
kaitejohnson Jun 26, 2024
d19fe05
remove attributes
kaitejohnson Jun 26, 2024
eeb3fe6
add bare bones componets of an R package
kaitejohnson Jun 26, 2024
1338587
update description
kaitejohnson Jun 26, 2024
112ae91
add description of package
kaitejohnson Jun 26, 2024
76d8574
Update README.md
kaitejohnson Jun 26, 2024
fcd6b15
fix pre-commit
kaitejohnson Jun 26, 2024
00fac5b
Merge branch 'format-as-package' of https://github.com/CDCgov/ww-infe…
kaitejohnson Jun 26, 2024
620d604
pre-commit on readme
kaitejohnson Jun 26, 2024
d8167b6
attempt to set up pkgdown
kaitejohnson Jun 26, 2024
178c1cf
correct path to deps
kaitejohnson Jun 26, 2024
9d444e8
remove call to package
kaitejohnson Jun 26, 2024
4f8ff3a
Create CODEOWNERS
kaitejohnson Jun 26, 2024
46f79c4
Create CONTRIBUTING.md
kaitejohnson Jun 26, 2024
45d949f
Create NEWS.md
kaitejohnson Jun 26, 2024
47364bd
Create SUPPORT.md
kaitejohnson Jun 26, 2024
9884e8c
add stan model and start of vignette
kaitejohnson Jun 27, 2024
70c69a5
start of generating simulated data
kaitejohnson Jun 27, 2024
d453696
add parameters, package, more documentation to gen simulated data
kaitejohnson Jun 28, 2024
513587b
add in functions for getting delay distributions
kaitejohnson Jun 28, 2024
fcad57a
add functions needed for generating simulated data
kaitejohnson Jun 28, 2024
e858a03
add simulated data as package data
kaitejohnson Jun 29, 2024
5a91ec8
add some initial pre-processing functions from other packages
kaitejohnson Jun 29, 2024
9afd74d
add functions to preprocess wastewater data
kaitejohnson Jun 30, 2024
f09fee2
add minimal hosp data preprocessing
kaitejohnson Jun 30, 2024
9f8ad5d
add internal package data for covid GI and delay
kaitejohnson Jun 30, 2024
c732701
add functions to create stan data, modify model to be more generally …
kaitejohnson Jun 30, 2024
900a5c7
simplify pre-processing in vignette
kaitejohnson Jul 1, 2024
6ead306
add draft of wrapper function to fit model
kaitejohnson Jul 1, 2024
d04ace0
add initialization functions
kaitejohnson Jul 1, 2024
e222e52
add a wrapper function around the model fitting
kaitejohnson Jul 2, 2024
0736f02
fix bug
kaitejohnson Jul 2, 2024
4f2a2d1
update gitignore to exclude stan binary and .Rproj
kaitejohnson Jul 2, 2024
3961d08
make it s.t. ww data needs a column called exclude, add preprocessing…
kaitejohnson Jul 3, 2024
d9bd1d7
add exclude column in preprocessing, make outlier flag optional step
kaitejohnson Jul 3, 2024
2a94332
add functions that set up model specification and mcmc options
kaitejohnson Jul 3, 2024
2894ae1
add wwinference function
kaitejohnson Jul 3, 2024
e6ef714
add post processing functions, realizing that I have an indexing erro…
kaitejohnson Jul 3, 2024
e8a3dfa
fix the handling of passing in col names, error was breaking LOD calling
kaitejohnson Jul 4, 2024
f5b314f
update documentation
kaitejohnson Jul 4, 2024
f558bd9
fix typo
kaitejohnson Jul 4, 2024
00c0543
adjust postprocess function, add in diagnostics
kaitejohnson Jul 5, 2024
f675dc4
add functions for quickly plotting outputs
kaitejohnson Jul 5, 2024
d272090
revert params back to current modle version
kaitejohnson Jul 5, 2024
728d83d
add plotting and diagnostics to vignette
kaitejohnson Jul 5, 2024
1028c72
fix merge conflicts with main from updating package infreastructure"
kaitejohnson Jul 5, 2024
f663ab6
fix merge conflicts with main from updating package infreastructure"
kaitejohnson Jul 5, 2024
06c8147
try running pre-commit locally
kaitejohnson Jul 5, 2024
64ab128
add dependences to DESCRIPTION
kaitejohnson Jul 5, 2024
fe88a39
add more deps
kaitejohnson Jul 5, 2024
b9c4eb8
try removing print statement
kaitejohnson Jul 5, 2024
56037c4
revert
kaitejohnson Jul 5, 2024
102da37
update vignette data
kaitejohnson Jul 5, 2024
b2d064e
fix typos
kaitejohnson Jul 5, 2024
9b3777f
remove example
kaitejohnson Jul 5, 2024
e770235
try adding bookdown to imports
kaitejohnson Jul 5, 2024
81ef6d8
fix to specify ISO8601 format for dates
kaitejohnson Jul 8, 2024
4cccf18
add ar1 testing functions
kaitejohnson Jul 8, 2024
74f0818
Create CI for package tests
kaitejohnson Jul 8, 2024
90dcdd2
Rename r-cmd-check to r-cmd-check.yaml
kaitejohnson Jul 8, 2024
098cb22
add rcmdcheck to package imports
kaitejohnson Jul 8, 2024
3980d04
Merge branch '9-port-over-tests' of https://github.com/CDCgov/ww-infe…
kaitejohnson Jul 8, 2024
cc05cd6
add ggplot2 dependency
kaitejohnson Jul 8, 2024
f290715
add way to generate testing data from model run and asve testing data
kaitejohnson Jul 8, 2024
c971abd
add vignette builder to DESCRIPTION
kaitejohnson Jul 8, 2024
12fb9da
add knitr to dependencies
kaitejohnson Jul 8, 2024
8d362f4
fix check of examples
kaitejohnson Jul 8, 2024
194e633
try fixing flag ww example, specify package for sym
kaitejohnson Jul 8, 2024
d7f335d
add dpyr to lag and lead terms
kaitejohnson Jul 8, 2024
3a5d7ec
add generation of test data to package
kaitejohnson Jul 8, 2024
6c49a08
add all the tests that are relevant from cdcgov repo
kaitejohnson Jul 8, 2024
b1d279a
add documentation for the package data
kaitejohnson Jul 8, 2024
12a8b06
fix the bugs identified by CI
kaitejohnson Jul 9, 2024
a3f9c56
fix example
kaitejohnson Jul 9, 2024
66a8b05
fix get params example
kaitejohnson Jul 9, 2024
8aa7f65
fix examples in indicate ww exclusions
kaitejohnson Jul 9, 2024
40146b9
fix example again, need exclude column going in
kaitejohnson Jul 9, 2024
0c0a7f4
fix hosp preprocessing examples
kaitejohnson Jul 9, 2024
c9091af
fix preprocess ww data example
kaitejohnson Jul 9, 2024
38e7352
fix redundancy bug in naming conc col name
kaitejohnson Jul 9, 2024
5650696
fix merge conflicts
kaitejohnson Jul 10, 2024
478e0a4
add posterior to imports
kaitejohnson Jul 10, 2024
0f33512
modify DESCRIPTION
kaitejohnson Jul 10, 2024
b9a6994
remove documentation for delay distrib fxns
kaitejohnson Jul 10, 2024
015c6b2
try adding knitr to imports
kaitejohnson Jul 10, 2024
0987581
Update pkgdown.yaml to generate on push to main
kaitejohnson Jul 10, 2024
2546249
add ggtitle to imports
kaitejohnson Jul 10, 2024
c894083
Merge branch '9-port-over-tests' of https://github.com/CDCgov/ww-infe…
kaitejohnson Jul 10, 2024
954aef0
move covid delay distribs into R/ but dont export
kaitejohnson Jul 10, 2024
e990f34
see if space allows fxn to be recognized in CI
kaitejohnson Jul 11, 2024
8a48077
remove example
kaitejohnson Jul 11, 2024
92240b0
remove all examples from non exported functions
kaitejohnson Jul 11, 2024
890a4db
remove postprocess
kaitejohnson Jul 11, 2024
17fe2a8
update documentation to remove postprocess
kaitejohnson Jul 11, 2024
3117d1b
Update .github/workflows/r-cmd-check.yaml
kaitejohnson Jul 12, 2024
5fca6dd
Update R/get_stan_data.R
kaitejohnson Jul 12, 2024
00834a3
fix little bugs
kaitejohnson Jul 12, 2024
c72e13d
remove extra stan file
kaitejohnson Jul 12, 2024
43d6e69
add package name in front of package fxns in data-raw
kaitejohnson Jul 12, 2024
1a72e09
fix switch for inits and rename
kaitejohnson Jul 12, 2024
5ba795c
remove knit from imports
kaitejohnson Jul 12, 2024
ed7a5a7
try adding knitr to suggests
kaitejohnson Jul 12, 2024
a0aa4a4
Update R/wwinference.R
kaitejohnson Jul 12, 2024
1ed01bb
update documentation
kaitejohnson Jul 12, 2024
3310d1d
fix precommit
kaitejohnson Jul 12, 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
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [prod]
branches: [main, prod]
pull_request:
branches: [main, prod]
release:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/r-cmd-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: R CMD check project packages

on:
pull_request:
push:
branches: [main, prod]

jobs:
check-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
use-public-rspm: true
extra-repositories: "https://mc-stan.org/r-packages/"
- name: "Set up dependencies for wwinference"
uses: r-lib/actions/setup-r-dependencies@v2
with:
needs: check
- name: "Install cmdstan via cmdstanr"
uses: epinowcast/actions/install-cmdstan@v1
with:
cmdstan-version: "latest"
- name: "Check wwinference package"
uses: r-lib/actions/check-r-package@v2
9 changes: 7 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Suggests:
testthat (>= 3.0.0),
bookdown
bookdown,
knitr
Config/testthat/edition: 3
LazyData: true
Imports:
Expand All @@ -78,6 +79,10 @@ Imports:
withr,
cmdstanr (>= 0.8.0),
rlang,
scales
scales,
ggplot2,
posterior
Remotes:
stan-dev/cmdstanr
VignetteBuilder:
knitr
18 changes: 18 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ importFrom(dplyr,as_tibble)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
importFrom(dplyr,group_by)
importFrom(dplyr,lag)
importFrom(dplyr,lead)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,ungroup)
importFrom(fs,path_package)
importFrom(ggplot2,aes)
importFrom(ggplot2,facet_grid)
importFrom(ggplot2,facet_wrap)
Expand All @@ -55,13 +58,28 @@ importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_ribbon)
importFrom(ggplot2,geom_vline)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggtitle)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_colour_discrete)
importFrom(ggplot2,scale_fill_discrete)
importFrom(ggplot2,scale_x_date)
importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,theme)
importFrom(lubridate,ymd)
importFrom(posterior,as_draws_list)
importFrom(posterior,subset_draws)
importFrom(rlang,sym)
importFrom(stats,dnbinom)
importFrom(stats,dweibull)
importFrom(stats,ecdf)
importFrom(stats,plogis)
importFrom(stats,qlogis)
importFrom(stats,rlnorm)
importFrom(stats,rnbinom)
importFrom(stats,rnorm)
importFrom(stats,rt)
importFrom(stats,sd)
importFrom(stats,time)
importFrom(tidybayes,spread_draws)
importFrom(tidybayes,stat_halfeye)
importFrom(tidybayes,stat_slab)
Expand Down
2 changes: 2 additions & 0 deletions R/checkers.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ check_date <- function(df, max_date, call = rlang::caller_env()) {
invisible()
}


#' Check that all elements of a vector are non-negative
#'
#' @param x vector of arguments to check for negativity
#' @param arg string to print the name of the element your checking
#' @param call Calling environment to be passed to the type checker
#'
#' @return NULL, invisibly
Expand Down
118 changes: 118 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#' Example wastewater dataset.
#'
#' A dataset containing the simulated wastewater concentrations
#' (labeled here as `genome_copies_per_ml`) by sample collection date (`date`),
#' the site where the sample was collected (`site`) and the lab where the
#' samples were processed (`lab`). Additional columns that are required
#' attributes needed for the model are the limit of detection for that lab on
#' each day (labeled here as `lod`) and the population size of the wastewater
#' catchment area represented by the wastewater concentrations in each `site`.
#'
#' This data is generated via the default values in the
#' `generate_simulated_data()` function. They represent the bare minumum
#' required fields needed to pass to the model, and we recommend that users
#' try to format their own data to match this format.
#'
#' The variables are as follows:
#'
#' @format ## ww_data
#' A tibble with 102 rows and 6 columns
#' \describe{
#' \item{date}{Sample collection date, formatted in ISO8601 standards as
#' YYYY-MM-DD}
#' \item{site}{The wastewater treatment plant where the sample was collected}
#' \item{lab}{The lab where the sample was processed}
#' \item{genome_copies_per_ml}{The wastewater concentration measured on the
#' date specified, collected in the site specified, and processed in the lab
#' specified. The default parameters assume that this quantity is reported
#' as the genome copies per mL, on a natural scale.}
#' \item{lod}{The limit of detection in the site and lab on a particular day
#' of the quantification device (e.g. PCR). This is also by default reported
#' in terms of the genome copies per mL.}
#' \item{site_pop}{The population size of the wastewater catchment area
#' represented by the site variable}
#' }
#' @source vignette_data.R
"ww_data"




#' Example hospital admissions dataset
#'
#' A dataset containing the simulated daily hospital admissions
#' (labeled here as `daily_hosp_admits`) by date of admission (`date`).
#' Additional columns that are required are the population size of the
#' population contributing to the hospital admissions. It is assumed that
#' the wastewater sites are subsets of this larger population, which
#' is in the package data assumed to be from a hypothetical US state.
#' The data generated are daily hospital admissions but they could be any other
#' epidemiological count dataset e.g. cases. This data should only contain
#' hospital admissions that would have been available as of the date that
#' the forecast was made. We recommend that users try to format their data
#' to match this format.
#'
#' This data is generated via the default values in the
#' `generate_simulated_data()` function. They represent the bare minumum
#' required fields needed to pass to the model, and we recommend that users
#' try to format their own data to match this formate.
#'
#' The variables are as follows:
#' \describe{
#' \item{date}{Date the hospital admissions occurred, formatte din ISO8601
#' standatds as YYYY-MM-DD}
#' \item{daily_hosp_admits}{The number of individuals admitted to the
#' hospital on that date, available as of the forecast date}
#' \item{state_pop}{The number of people contributing to the daily hospital
#' admissions}
#' }
#' @source vignette_data.R
"hosp_data"

#' Example hospital admissions dataset for evaluation
#'
#' A dataset containing the simulated daily hospital admissions that the model
#' will be evaluated against (labeled here as `daily_hosp_admits_for_eval`)
#' by date of admission (`date`). This data is not needed to fit the model,
#' but is used in the Getting Started vignette to demonstrate the forecasted
#' hospital admissions compared to those later observed.
#'
#' This data is generated via the default values in the
#' `generate_simulated_data()` function.
#'
#' The variables are as follows:
#' \describe{
#' \item{date}{Date the hospital admissions occurred, formatte din ISO8601
#' standatds as YYYY-MM-DD}
#' \item{daily_hosp_admits_for_eval}{The number of individuals admitted to the
#' hospital on that date, available beyond the forecast date for evaluating
#' the forecasted hospital admissions}
#' \item{state_pop}{The number of people contributing to the daily hospital
#' admissions}
#' }
#' @source vignette_data.R
"hosp_data_eval"

#' COVID-19 post-Omicron generation interval probability mass function
#'
#' \describe{
#' A vector that sums to 1, with each element representing the daily
#' probability of secondary onward transmission occurring on that day. The
#' first element of this vector represents the day after primary transmission
#' occurred, it is assumed to be impossible for primary and secondary
#' transmission to occur on the same day.
#' }
#' @source covid_pmfs.R
"generation_interval"

#' COVID-19 time delay distribution from infection to hospital admission
#'
#' \describe{
#' A vector that sums to 1, with each element representing the daily
#' probabilty of transitioning from infected to hospitalized, conditioned on
#' being infected and eventually ending up hospitalized. The first element
#' represents the probability of being infected and admitted to the hospital
#' on the same day
#' }
#' @source covid_pmfs.R
"inf_to_hosp"
Loading
Loading