-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from matsim-org/develop
Develop
- Loading branch information
Showing
88 changed files
with
11,713 additions
and
1,771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
library(lubridate) | ||
library(tidyverse) | ||
library(readr) | ||
|
||
|
||
|
||
rm(list=ls()) | ||
source("/Users/jakob/git/matsim-episim/src/main/R/masterJR-utils.R", encoding = 'utf-8') | ||
|
||
# Global variables | ||
directory <- "/Users/jakob/git/public-svn/matsim/scenarios/countries/de/episim/battery/jakob/2022-07-27/4-eu-noAgg/" | ||
|
||
origin_date <- ymd("2022-07-24") # first day (sunday) of epiweek 30, 2022 | ||
end_date <- ymd("2023-07-29") # last day (saturday) of epiweek 30, 2023 (latest possible value) | ||
|
||
|
||
|
||
## read & prep infections | ||
infections_raw <- read_combine_episim_output_zipped(directory,"infections.txt.csv") | ||
|
||
infections_incidence <- convert_infections_into_incidence(directory,infections_raw,FALSE) %>% | ||
select(-c(infections_week,nShowingSymptomsCumulative, district, incidence)) | ||
|
||
|
||
population_cologne <- infections_raw[1, "nSusceptible"] | ||
|
||
population_germany <- 83695430 #https://www.destatis.de/EN/Themes/Society-Environment/Population/Current-Population/Tables/liste-current-population.html | ||
scale_factor <- population_germany / population_cologne # pop germany / pop koelln | ||
|
||
infections_ready <- infections_incidence %>% | ||
filter(date >= origin_date & date <= end_date) %>% | ||
# mutate(weekday = lubridate::wday(date, label = TRUE)) %>% | ||
mutate(year = epiyear(date)) %>% | ||
mutate(epiweek = epiweek(date)) %>% | ||
group_by(seed,vacCamp,vacType,year,epiweek) %>% | ||
summarise(value = sum(infections) * scale_factor, target_end_date = last(date) ) %>% | ||
mutate(target_variable = "inc infection") %>% | ||
select(year, epiweek, target_end_date, target_variable, value, seed, vacCamp, vacType) | ||
|
||
|
||
## read & prep hospitalizations | ||
hosp_raw <- read_combine_episim_output_zipped(directory,"post.hospital.tsv") | ||
|
||
hosp_ready <- hosp_raw %>% | ||
filter(date >= origin_date & date <= end_date) %>% | ||
mutate(year = year(date)) %>% | ||
mutate(wkday = lubridate::wday(date, label = TRUE)) %>% | ||
filter(wkday == "Sat") %>% | ||
filter(measurement == "intakesHosp") %>% | ||
filter(severity == "Omicron") %>% | ||
mutate(epiweek = epiweek(date)) %>% | ||
rename("target_end_date" = date, value = n) %>% | ||
mutate(value = value * population_cologne / 100000 * scale_factor) %>% | ||
mutate(target_variable = "inc hosp") %>% | ||
select(year, epiweek, target_end_date, target_variable, value, seed, vacCamp, vacType) | ||
|
||
# combine two dataframes and modify columns to match specs | ||
combined <- rbind(infections_ready, hosp_ready) | ||
# combined <- infections_ready #todo revert | ||
|
||
|
||
|
||
|
||
seed <- unique(combined$seed) | ||
sample <- seq(length(seed)) | ||
map <- data.frame(seed,sample) | ||
|
||
final <- combined %>% filter(vacCamp!="off") %>% | ||
mutate(scenario_id = paste0(vacCamp,"_",vacType)) %>% | ||
mutate(scenario_id = case_when(scenario_id == "60plus_omicronUpdate"~"A-2022-07-24", | ||
scenario_id == "18plus_omicronUpdate"~"B-2022-07-24", | ||
scenario_id == "60plus_mRNA"~"C-2022-07-24", | ||
scenario_id == "18plus_mRNA"~"D-2022-07-24")) %>% | ||
merge(map,by ="seed") %>% | ||
mutate(horizon = case_when(year == 2022 ~ epiweek - 29, year == 2023~ (52-29) + epiweek)) %>% | ||
mutate("origin_date" = "2022-07-24") %>% | ||
mutate("location" = "DE") %>% | ||
mutate(value = round(value)) %>% | ||
select(origin_date,scenario_id, horizon, target_end_date, location, sample,target_variable, value) %>% | ||
arrange(scenario_id,sample,horizon) %>% | ||
mutate(horizon = paste0(horizon," wk")) | ||
|
||
write.csv(final,"/Users/jakob/git/covid19-scenario-hub-europe/data-processed/MODUS_Covid-Episim/2022-07-24-MODUS_Covid-Episim.csv", row.names = FALSE) | ||
|
||
|
||
|
||
# xxx <- read.delim("/Users/jakob/antibodies_2022-07-23.tsv",sep = "\t") | ||
# | ||
# yyy <- xxx %>% filter(nVaccinations == 0 & nInfections == 0) | ||
# | ||
# nrow(yyy)/nrow(xxx) | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
library(lubridate) | ||
library(tidyverse) | ||
library(readr) | ||
|
||
|
||
|
||
rm(list=ls()) | ||
source("/Users/jakob/git/matsim-episim/src/main/R/masterJR-utils.R", encoding = 'utf-8') | ||
|
||
# directory_snap_old <- "/Users/jakob/git/public-svn/matsim/scenarios/countries/de/episim/battery/jakob/2022-11-05/2-imm-snap/" | ||
directory_base <- "/Users/jakob/git/public-svn/matsim/scenarios/countries/de/episim/battery/jakob/2022-11-24/1-makeImmHist/" | ||
directory_imm <- "/Users/jakob/git/public-svn/matsim/scenarios/countries/de/episim/battery/jakob/2022-11-24/3-imm-20seeds/" | ||
# file_root<- "antibodies.tsv" | ||
|
||
#infections | ||
file_root_inf<- "infections.txt.csv" | ||
snap_inf_raw <- read_combine_episim_output_zipped(directory_base, file_root_inf ) | ||
# snap_inf_raw_old <- read_combine_episim_output_zipped(directory_snap, file_root_inf ) | ||
imm_inf_raw <- read_combine_episim_output_zipped(directory_imm, file_root_inf) | ||
|
||
unique(snap_inf_raw$seed) | ||
|
||
|
||
start_date <- ymd("2022-04-01") | ||
end_date <- ymd("2022-09-01") | ||
snap_inf <- snap_inf_raw %>% | ||
filter(date >= start_date) %>% | ||
filter(date <= end_date) %>% | ||
filter(seed %in% unique(imm_inf_raw$seed)) | ||
# filter(pHh == 0.0, immuneSigma == 0.0) | ||
# mutate(vax = generic + mRNA + vector + ba1Update + ba5Update + natural) | ||
|
||
|
||
imm_inf <- imm_inf_raw %>% | ||
filter(date >= start_date) %>% | ||
filter(date <= end_date) %>% | ||
filter(StrainA == 2.0 & startFromImm =="sepSeeds") | ||
|
||
|
||
# mutate(vax = generic + mRNA + vector + ba1Update + ba5Update + natural) | ||
ggplot() + #nShowingSymptoms # SARS_CoV_2 | ||
geom_line(imm_inf, mapping = aes(date, nShowingSymptoms , group = seed, col = "imm-hist")) + | ||
geom_line(snap_inf, mapping = aes(date, nShowingSymptoms , group = seed, col = "snapshot")) + | ||
scale_color_manual(name='Regression Model', | ||
breaks=c('snapshot', 'imm-hist'), | ||
values=c('snapshot'='red', 'imm-hist'='blue'))+ | ||
labs(alt = "hello world") + | ||
ggtitle("Infections") | ||
|
||
|
||
|
||
# antibodies | ||
file_root_ab<- "antibodies.tsv" | ||
snap_ab_raw <- read_combine_episim_output_zipped(directory_base, file_root_ab ) | ||
imm_ab_raw <- read_combine_episim_output_zipped(directory_imm, file_root_ab) | ||
|
||
|
||
start_date <- ymd("2021-11-15") | ||
end_date <- ymd("2029-11-30") | ||
snap_ab <- snap_ab_raw %>% | ||
filter(date >= start_date) %>% | ||
filter(date <= end_date) %>% | ||
filter(pHh == 0.0, immuneSigma == 0.0) | ||
# mutate(vax = generic + mRNA + vector + ba1Update + ba5Update + natural) | ||
imm_ab <- imm_ab_raw %>% | ||
filter(date >= start_date) %>% | ||
filter(date <= end_date) %>% | ||
filter(pHh == 0.0, immuneSigma == 0.0) | ||
# mutate(vax = generic + mRNA + vector + ba1Update + ba5Update + natural) | ||
ggplot() + #nShowingSymptoms # SARS_CoV_2 | ||
geom_line(imm_ab, mapping = aes(date, SARS_CoV_2 , group = seed, col = "imm-hist")) + | ||
geom_line(snap_ab, mapping = aes(date, SARS_CoV_2 , group = seed, col = "snapshot")) + | ||
scale_color_manual(name='Regression Model', | ||
breaks=c('snapshot', 'imm-hist'), | ||
values=c('snapshot'='red', 'imm-hist'='blue'))+ | ||
ggtitle("Antibodies") | ||
|
||
|
||
|
||
|
||
# scale_colour_manual(name = "scenario", values = c("red"="red", "blue"="blue"), labels = c("snapshot", "immune history")) + | ||
# facet_wrap(pHh ~ immuneSigma) | ||
|
||
# antibodies are a bit lower for immune history people | ||
# jump in snapshot on first day is a bit sus... (maybe there is something wrong there..., not with immune history)) | ||
# what happens to Antibodies from June 30 to July 1?? Why do they jump? | ||
|
||
# infections: now imm-Hist (blue) run has lower case numbers... too many antibodies or whats going on? | ||
# but blue also has slightly lower antibodies. How can this be? |
Oops, something went wrong.