-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_targets.R
More file actions
111 lines (100 loc) · 2.56 KB
/
_targets.R
File metadata and controls
111 lines (100 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Targets script for analysing forecasts and scores
# This pipeline assumes that the `output/` folder contains:
# - overall_data_all_runs/scores.csv: a single file with all of the scores
# for all forecasts for the 3 models (wwinference with and without ww and
# baseline ARIMA)
# - individual_forecasts_all_runs/{forecast_date}/{location}/data: hospital
# admissions quantiles for wwinference with and without wastewater, R(t)
# estimates for the location with and without wastewater, and predicted
# quantiled wastewater concentrations
# The pipeline can be run using `tar_make()`
library(targets)
library(jsonlite)
library(httr)
library(tarchetypes)
library(wwinference)
library(dplyr)
library(ggplot2)
library(readr)
library(here)
library(purrr)
library(lubridate)
library(tidyr)
library(glue)
library(fs)
library(rlang)
library(scoringutils)
library(forecast)
library(future)
library(future.callr)
# load functions
functions <- list.files(here("R"), full.names = TRUE)
walk(functions, source)
rm("functions")
# load target modules
targets <- list.files(here("targets"), full.names = TRUE)
targets <- grep("*\\.R", targets, value = TRUE)
purrr::walk(targets, source)
tar_option_set(
packages = c(
"wwinference",
"tibble",
"dplyr",
"ggplot2",
"readr",
"lubridate",
"tidyr",
"glue",
"forecast",
"jsonlite",
"httr"
),
workspace_on_error = TRUE,
storage = "worker",
retrieval = "worker",
memory = "transient",
garbage_collection = TRUE,
format = "parquet", # default storage format
error = "continue"
)
# Analysis config
analysis_config <- list(
# Full set of dates and locations and models for which the model
# was run for
create_permutations_targets,
# Set of dates and locations to focus on in example figures +
# specifications of any post-processing model outputs
analysis_config_targets
)
# Wastewater and state metadata
get_metadata <- list(
tar_target(
name = ww_metadata,
command = read_csv(ww_metadat_fp)
),
tar_target(
name = state_pop_data,
command = get_state_pop_data()
)
)
# Secondary outputs
secondary_outputs <- list(
# GAM meta-model on scores ()
run_gam_targets
# compute coverage metrics (?)
)
# Figures
plot_targets <- list(
analysis_EDA_plot_targets
# Fig 1: visual comparison for a single forecast date
# Fig 2: visual comparison + scores across forecast dates
# Fig 3: overall, by horizon, by location, by forecast date
# by location and forecast date
# Fig 4: Model-based evaluation results
)
list(
analysis_config,
get_metadata,
secondary_outputs,
plot_targets
)