Skip to content

Commit ced5289

Browse files
DanWeinbergerclaude
andcommitted
Add ILINet (FluView) data to respiratory bundle
Include delphi_ili_fluview weighted ILI percentage as a flu indicator in the respiratory bundle. Simplify epiweek-to-date conversion in ingest.R and remove commented-out experimental code from build.R. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e678a07 commit ced5289

File tree

7 files changed

+284
-68
lines changed

7 files changed

+284
-68
lines changed

data/bundle_respiratory/build.R

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ bundle_files <- list( '../epic/standard/weekly.csv.gz',
3131
'../wastewater/standard/data.csv.gz',
3232
'../delphi_doctors_claims/standard/data.csv.gz',
3333
'../delphi_hospital_claims/standard/data.csv.gz',
34-
'../delphi_nhsn/standard/data.csv.gz'
34+
'../delphi_nhsn/standard/data.csv.gz',
35+
'../delphi_ili_fluview/standard/data.csv.gz'
3536
)
3637

3738
start_time <- "2020"
@@ -60,43 +61,6 @@ combined <- Reduce(
6061
#colnames(combined) <- sub("n_", "epic_", colnames(combined), fixed = TRUE)
6162

6263

63-
64-
############################
65-
############################
66-
#Experimental: try to just create one big output table
67-
# output_table <- combined %>%
68-
# pivot_longer(
69-
# cols = where(is.numeric),
70-
# names_to = "metric",
71-
# values_to = "value"
72-
# ) %>%
73-
# arrange(geography, metric, time) %>%
74-
# group_by(geography, metric) %>%
75-
# mutate(
76-
# value_smooth = zoo::rollapplyr(value, 3, mean, partial = TRUE, na.rm = TRUE),
77-
# value_smooth_scale = value_smooth / max(value_smooth, na.rm = TRUE) * 100
78-
# ) %>%
79-
# ungroup() %>%
80-
# pivot_wider(
81-
# names_from = metric,
82-
# values_from = c(value, value_smooth, value_smooth_scale),
83-
# names_sep = "_"
84-
# )
85-
# vroom::vroom_write(
86-
# output_table,
87-
# "dist/TEST_mega.csv.gz",
88-
# ","
89-
# )
90-
# arrow::write_parquet(output_table,
91-
# "dist/TEST_mega.parquet")
92-
#
93-
# jsonlite::write_json(output_table, gzfile("dist/TEST_mega.json.gz"), dataframe = "columns") #way too big
94-
95-
####################################
96-
####################################
97-
####################################
98-
99-
10064
overall_trends <- combined %>%
10165
filter( (time >= max(time) - 365*2) & geography %in% state_fips) %>%
10266
rename(fips= geography) %>%
@@ -175,7 +139,7 @@ overall_trends %>%
175139

176140
overall_trends %>%
177141
filter(grepl('flu',variable) & !is.na(value)) %>%
178-
filter(variable %in% c('epic_pct_flu', 'percent_visits_flu', 'rate_flu','wastewater_flua','delphi_nhsn_flu' ,'delphi_hospital_flu_smooth')) %>%
142+
filter(variable %in% c('epic_pct_flu', 'percent_visits_flu', 'rate_flu','wastewater_flua','delphi_nhsn_flu' ,'delphi_hospital_flu_smooth','delphi_fluview_wili')) %>%
179143
mutate( source = if_else(variable=='epic_pct_flu', 'Epic Cosmos, ED',
180144
if_else(variable=='percent_visits_flu', 'CDC NSSP',
181145
if_else(variable=='rate_flu', 'CDC RespNET',
0 Bytes
Binary file not shown.
204 KB
Binary file not shown.
0 Bytes
Binary file not shown.

data/delphi_ili_fluview/ingest.R

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,8 @@ if (!identical(process$raw_state, raw_state)) {
6363
!is.na(geography) ~ geography, # Use merged FIPS code
6464
TRUE ~ NA_character_ # Should not happen if lookup is complete
6565
),
66-
# Convert epiweek to date (Saturday at end of week)
67-
# Epiweek format: YYYYWW (e.g., 202301 = 2023 week 1)
68-
epiweek_year = as.integer(substr(as.character(epiweek), 1, 4)),
69-
epiweek_week = as.integer(substr(as.character(epiweek), 5, 6)),
70-
# Calculate Saturday ending the epiweek
71-
# MMWR week 1 always contains Jan 4, and weeks run Sunday-Saturday
72-
# Find Jan 4 of the year, get its MMWR week start (Sunday), then add weeks
73-
jan4 = as.Date(paste0(epiweek_year, "-01-04")),
74-
# Find the Sunday of the week containing Jan 4
75-
jan4_wday = lubridate::wday(jan4, week_start = 7), # Sunday = 1
76-
week1_sunday = jan4 - (jan4_wday - 1),
77-
# Calculate the Saturday of the requested epiweek
78-
time = week1_sunday + (epiweek_week - 1) * 7 + 6 # +6 to get Saturday
66+
# Convert epiweek (YYYY-mm-dd Sunday) to Saturday end-of-week
67+
time = as.Date(epiweek) + 6
7968
) %>%
8069
# Select and rename columns to standard format
8170
# wili = weighted ILI percentage, ili = unweighted ILI percentage

data/delphi_ili_fluview/process.json

Lines changed: 279 additions & 16 deletions
Large diffs are not rendered by default.
68 KB
Binary file not shown.

0 commit comments

Comments
 (0)