Skip to content

440 epiprocess imports #444

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

Merged
merged 10 commits into from
Feb 26, 2025
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: epipredict
Title: Basic epidemiology forecasting methods
Version: 0.1.10
Version: 0.1.11
Authors@R: c(
person("Daniel J.", "McDonald", , "[email protected]", role = c("aut", "cre")),
person("Ryan", "Tibshirani", , "[email protected]", role = "aut"),
Expand All @@ -25,14 +25,14 @@ URL: https://github.com/cmu-delphi/epipredict/,
BugReports: https://github.com/cmu-delphi/epipredict/issues/
Depends:
epidatasets,
epiprocess (>= 0.10.4),
parsnip (>= 1.0.0),
R (>= 3.5.0)
Imports:
checkmate,
cli,
distributional,
dplyr,
epiprocess (>= 0.10.4),
generics,
ggplot2,
glue,
Expand Down
16 changes: 16 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export(arx_class_epi_workflow)
export(arx_classifier)
export(arx_fcast_epi_workflow)
export(arx_forecaster)
export(as_epi_df)
export(as_tibble)
export(autoplot)
export(bake)
export(cdc_baseline_args_list)
Expand All @@ -160,6 +162,7 @@ export(extract_argument)
export(extract_frosting)
export(extract_layers)
export(extrapolate_quantiles)
export(filter)
Copy link
Contributor

Choose a reason for hiding this comment

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

musing: this does introduce a conflict with stats::filter, but I guess eventually we should be providing our own convolution utilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that will happen anytime dplyr is used. This would have happened before anyway since epiprocess was in Depends and it exports filter().

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... I'm not sure why we export filter from epiprocess; shouldn't be necessary just to provide an S3 method.

Copy link
Contributor

@brookslogan brookslogan Feb 27, 2025

Choose a reason for hiding this comment

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

We could make this happen only when user attaches dplyr themselves. I guess if users are using [dplyr filter] a lot [seems likely] though then it might make sense to re-export. It's just that convolution does seem somewhat popular with potential users.

export(fit)
export(flatline)
export(flatline_args_list)
Expand All @@ -171,6 +174,7 @@ export(get_test_data)
export(is_epi_recipe)
export(is_epi_workflow)
export(is_layer)
export(key_colnames)
export(layer)
export(layer_add_forecast_date)
export(layer_add_target_date)
Expand All @@ -184,17 +188,22 @@ export(layer_quantile_distn)
export(layer_residual_quantiles)
export(layer_threshold)
export(layer_unnest)
export(mutate)
export(nested_quantiles)
export(new_default_epi_recipe_blueprint)
export(new_epi_recipe_blueprint)
export(pivot_longer)
export(pivot_quantiles_longer)
export(pivot_quantiles_wider)
export(pivot_wider)
export(prep)
export(quantile_reg)
export(rand_id)
export(remove_epi_recipe)
export(remove_frosting)
export(remove_model)
export(rename)
export(select)
export(slather)
export(smooth_quantile_reg)
export(step_adjust_latency)
Expand All @@ -208,6 +217,7 @@ export(step_population_scaling)
export(step_training_window)
export(tibble)
export(tidy)
export(unnest)
export(update_epi_recipe)
export(update_frosting)
export(update_model)
Expand Down Expand Up @@ -256,8 +266,12 @@ importFrom(dplyr,summarize)
importFrom(dplyr,tibble)
importFrom(dplyr,tribble)
importFrom(dplyr,ungroup)
importFrom(epiprocess,as_epi_df)
importFrom(epiprocess,epi_slide)
importFrom(epiprocess,growth_rate)
importFrom(epiprocess,growth_rate_params)
importFrom(epiprocess,is_epi_df)
importFrom(epiprocess,key_colnames)
importFrom(generics,augment)
importFrom(generics,fit)
importFrom(generics,forecast)
Expand Down Expand Up @@ -316,6 +330,8 @@ importFrom(tidyr,crossing)
importFrom(tidyr,drop_na)
importFrom(tidyr,expand_grid)
importFrom(tidyr,fill)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,unnest)
importFrom(tidyselect,all_of)
importFrom(utils,capture.output)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Pre-1.0.0 numbering scheme: 0.x will indicate releases, while 0.0.x will indicat
- Addresses upstream breaking changes from cmu-delphi/epiprocess#595 (`growth_rate()`).
`step_growth_rate()` has lost its `additional_gr_args_list` argument and now
has an `na_rm` argument.
- Moves `epiprocess` out of depends (#440). No internals have changed, but downstream
users may need to add `library(epiprocess)` to existing code.

## Improvements

Expand Down
2 changes: 0 additions & 2 deletions R/arx_classifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#' @seealso [arx_class_epi_workflow()], [arx_class_args_list()]
#'
#' @examples
#' library(dplyr)
#' tiny_geos <- c("as", "mp", "vi", "gu", "pr")
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"), !(geo_value %in% tiny_geos))
Expand Down Expand Up @@ -107,7 +106,6 @@ arx_classifier <- function(
#' @export
#' @seealso [arx_classifier()] [arx_class_args_list()]
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"))
#'
Expand Down
1 change: 0 additions & 1 deletion R/arx_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ arx_forecaster <- function(
#' @seealso [arx_forecaster()]
#'
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-12-01"))
#'
Expand Down
1 change: 0 additions & 1 deletion R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ggplot2::autoplot
#'
#' @name autoplot-epipred
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value >= as.Date("2021-11-01"))
#'
Expand Down
38 changes: 19 additions & 19 deletions R/cdc_baseline_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#'
#' @examples
#' library(dplyr)
#' library(epiprocess)
#' weekly_deaths <- covid_case_death_rates %>%
#' select(geo_value, time_value, death_rate) %>%
#' left_join(state_census %>% select(pop, abbr), by = c("geo_value" = "abbr")) %>%
Expand All @@ -36,25 +37,24 @@
#' cdc <- cdc_baseline_forecaster(weekly_deaths, "deaths_7dsum")
#' preds <- pivot_quantiles_wider(cdc$predictions, .pred_distn)
#'
#' if (require(ggplot2)) {
#' forecast_date <- unique(preds$forecast_date)
#' four_states <- c("ca", "pa", "wa", "ny")
#' preds %>%
#' filter(geo_value %in% four_states) %>%
#' ggplot(aes(target_date)) +
#' geom_ribbon(aes(ymin = `0.1`, ymax = `0.9`), fill = blues9[3]) +
#' geom_ribbon(aes(ymin = `0.25`, ymax = `0.75`), fill = blues9[6]) +
#' geom_line(aes(y = .pred), color = "orange") +
#' geom_line(
#' data = weekly_deaths %>% filter(geo_value %in% four_states),
#' aes(x = time_value, y = deaths_7dsum)
#' ) +
#' scale_x_date(limits = c(forecast_date - 90, forecast_date + 30)) +
#' labs(x = "Date", y = "Weekly deaths") +
#' facet_wrap(~geo_value, scales = "free_y") +
#' theme_bw() +
#' geom_vline(xintercept = forecast_date)
#' }
#' library(ggplot2)
#' forecast_date <- unique(preds$forecast_date)
#' four_states <- c("ca", "pa", "wa", "ny")
#' preds %>%
#' filter(geo_value %in% four_states) %>%
#' ggplot(aes(target_date)) +
#' geom_ribbon(aes(ymin = `0.1`, ymax = `0.9`), fill = blues9[3]) +
#' geom_ribbon(aes(ymin = `0.25`, ymax = `0.75`), fill = blues9[6]) +
#' geom_line(aes(y = .pred), color = "orange") +
#' geom_line(
#' data = weekly_deaths %>% filter(geo_value %in% four_states),
#' aes(x = time_value, y = deaths_7dsum)
#' ) +
#' scale_x_date(limits = c(forecast_date - 90, forecast_date + 30)) +
#' labs(x = "Date", y = "Weekly deaths") +
#' facet_wrap(~geo_value, scales = "free_y") +
#' theme_bw() +
#' geom_vline(xintercept = forecast_date)
cdc_baseline_forecaster <- function(
epi_data,
outcome,
Expand Down
45 changes: 0 additions & 45 deletions R/create-layer.R

This file was deleted.

19 changes: 4 additions & 15 deletions R/epi_recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@ epi_recipe <- function(x, ...) {
#'
#' @export
#' @examples
#' library(dplyr)
#' library(recipes)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-08-01") %>%
#' arrange(geo_value, time_value)
#' filter(time_value > "2021-08-01")
#'
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
#' step_epi_ahead(death_rate, ahead = 7) %>%
#' step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
#' step_naomit(all_predictors()) %>%
#' # below, `skip` means we don't do this at predict time
#' step_naomit(all_outcomes(), skip = TRUE)
#' step_epi_naomit()
#'
#' r
epi_recipe.epi_df <- function(x,
Expand Down Expand Up @@ -271,19 +266,14 @@ is_epi_recipe <- function(x) {
#'
#' @export
#' @examples
#' library(dplyr)
#' library(recipes)
#'
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-08-01") %>%
#' arrange(geo_value, time_value)
#' filter(time_value > "2021-08-01")
#'
#' r <- epi_recipe(jhu) %>%
#' step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
#' step_epi_ahead(death_rate, ahead = 7) %>%
#' step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
#' step_naomit(all_predictors()) %>%
#' step_naomit(all_outcomes(), skip = TRUE)
#' step_epi_naomit()
#'
#' workflow <- epi_workflow() %>%
#' add_epi_recipe(r)
Expand Down Expand Up @@ -355,7 +345,6 @@ update_epi_recipe <- function(x, recipe, ..., blueprint = default_epi_recipe_blu
#'
#' @export
#' @examples
#' library(dplyr)
#' library(workflows)
#'
#' jhu <- covid_case_death_rates %>%
Expand Down
2 changes: 1 addition & 1 deletion R/epipredict-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#' @importFrom dplyr full_join relocate summarise everything
#' @importFrom dplyr inner_join
#' @importFrom dplyr summarize filter mutate select left_join rename ungroup
#' @importFrom epiprocess growth_rate growth_rate_params is_epi_df
#' @importFrom magrittr extract2
#' @importFrom rlang := !! %||% as_function global_env set_names !!! caller_arg
#' @importFrom rlang is_logical is_true inject enquo enquos expr sym arg_match
#' @importFrom stats poly predict lm residuals quantile
#' @importFrom tibble as_tibble
na_chr <- NA_character_
## usethis namespace: end
NULL
1 change: 1 addition & 0 deletions R/flusight_hub_formatter.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ abbr_to_location <- function(abbr) {
#'
#' @examples
#' library(dplyr)
#' library(epiprocess)
#' weekly_deaths <- covid_case_death_rates %>%
#' filter(
#' time_value >= as.Date("2021-09-01"),
Expand Down
3 changes: 0 additions & 3 deletions R/frosting.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @export
#'
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
Expand Down Expand Up @@ -127,7 +126,6 @@ update_frosting <- function(x, frosting, ...) {
#'
#' @export
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
Expand Down Expand Up @@ -262,7 +260,6 @@ new_frosting <- function() {
#' @export
#'
#' @examples
#' library(dplyr)
#' # Toy example to show that frosting can be created and added for postprocessing
#' f <- frosting()
#' wf <- epi_workflow() %>% add_frosting(f)
Expand Down
1 change: 0 additions & 1 deletion R/layer_add_forecast_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#'
#' @export
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
Expand Down
1 change: 0 additions & 1 deletion R/layer_add_target_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#'
#' @export
#' @examples
#' library(dplyr)
#' jhu <- covid_case_death_rates %>%
#' filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
#' r <- epi_recipe(jhu) %>%
Expand Down
Loading