Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
melodiemonod committed Oct 1, 2020
1 parent 5b06ae6 commit 2f98e51
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
20 changes: 15 additions & 5 deletions covid19AgeModel/inst/scripts/post-processing-etas.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ if(!file.exists(file) | args_dir[['overwrite']])
cat("\nWrite ",file," ... ")
saveRDS(mcnts, file=file)
file2 <- gsub('_by_age','',file)
cat("\nWrite ",file," ... ")
cat("\nWrite ",file2," ... ")
saveRDS(ocnts, file=file2)
})
cat(" \n -------------------------------- \n summarise marginal contact intensities by age: end \n -------------------------------- \n")
}
if(file.exists(file))
{
mcnts <- readRDS(file)
file <- gsub('_by_age','',file)
ocnts <- readRDS(file)
file2 <- gsub('_by_age','',file)
ocnts <- readRDS(file2)
}

# handle if forecast period is to be included in plots
Expand Down Expand Up @@ -189,7 +189,17 @@ file <- paste0(outfile.base,'-marginal_contact_intensities_across_states_weighte
if(!file.exists(file) | args_dir[['overwrite']])
{
cat(" \n -------------------------------- \n summarise marginal contact intensities across states: start \n -------------------------------- \n")
tryCatch({
tryCatch({
round.choose <- function(x, roundTo, dir = 1) {
if(dir == 1) { ##ROUND UP
x + (roundTo - x %% roundTo)
} else {
if(dir == 0) { ##ROUND DOWN
x - (x %% roundTo)
}
}
}

weighted_contacts <- make_contact_intensities_across_states_summaries(plot.pars.basic$regions,
plot.pars.basic$mobility_data,
plot.pars.basic$dates,
Expand Down Expand Up @@ -220,7 +230,7 @@ if(!file.exists(file) | args_dir[['overwrite']])
file2 <- paste0(outfile.base,'-marginal_contact_intensities_across_states_weighted_age.rds')
saveRDS(age_specific, file=file2, version = 2)

p <- make_age_contact_boxplot(age_specific, outfile.base)
#p <- make_age_contact_boxplot(age_specific, outfile.base)


})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# post-processing-make-deaths-panel-plot.R
# post-processing-make-daily-weekly-deaths-expected-observed-plot.R
#
###############################################################################

cat(" \n -------------------------------- \n \n post-processing-make-deaths-panel-plot.R \n \n -------------------------------- \n")
cat(" \n -------------------------------- \n \n post-processing-make-daily-weekly-deaths-expected-observed-plot.R \n \n -------------------------------- \n")

suppressMessages(library(data.table, quietly = TRUE))
suppressMessages(library(bayesplot, quietly = TRUE))
Expand Down Expand Up @@ -130,3 +130,5 @@ df.weekly = find_observed_death_fourageband(e_adeaths_weekly, "weekly")

plot_expected_observed_death(df.daily, "daily")
plot_expected_observed_death(df.weekly, "weekly")

cat(" \n -------------------------------- \n \n Completed post-processing-make-daily-weekly-deaths-expected-observed-plot.R \n \n -------------------------------- \n")
15 changes: 11 additions & 4 deletions covid19AgeModel/inst/scripts/post-processing-plot-age-newcases.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# post-processing-plot-mean-age-newcases.R
# post-processing-plot-age-newcases.R
#
###############################################################################

cat(" \n -------------------------------- \n \n Running post-processing-plot-mean-age-newcases.R \n \n -------------------------------- \n")
cat(" \n -------------------------------- \n \n Running post-processing-plot-age-newcases.R \n \n -------------------------------- \n")

suppressMessages(library(data.table, quietly = TRUE))
suppressMessages(library(bayesplot, quietly = TRUE))
Expand Down Expand Up @@ -82,6 +82,10 @@ if(!file.exists(file) | args_dir[['overwrite']])
cat("\nWrite ",file," ... ")
saveRDS(e_newcases_byage_c, file=file)
}
if(file.exists(file))
{
e_newcases_byage_c <- readRDS(file)
}
cat("\n ----------- plot_proportion_newcases_byage_c ----------- \n")

#
Expand Down Expand Up @@ -134,7 +138,10 @@ if(!file.exists(file) | args_dir[['overwrite']])
cat("\nWrite ",file," ... ")
saveRDS(e_age_newcases, file=file)
}

if(file.exists(file))
{
e_age_newcases <- readRDS(file)
}
cat("\n ----------- plot_mean_age_new_cases ----------- \n")

#
Expand Down Expand Up @@ -168,4 +175,4 @@ ggplot(e_age_newcases, aes(x = date)) +
scale_colour_viridis(begin=0,end=1,direction=-1) +
ggsave(paste0(outfile.base,'-mean_ageofinfection.png'), w = 210, h = 310, units = "mm")

cat(" \n -------------------------------- \n \n Completed post-processing-plot-mean-age-newcases.R \n \n -------------------------------- \n")
cat(" \n -------------------------------- \n \n Completed post-processing-plot-age-newcases.R \n \n -------------------------------- \n")
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# post-processing-validate-prop_antibodys.R
# post-processing-summarise-antibody.R
#
###############################################################################

cat(" \n -------------------------------- \n \n post-processing-validate-prop_antibodys.R \n \n -------------------------------- \n")
cat(" \n -------------------------------- \n \n post-processing-summarise-antibody.R \n \n -------------------------------- \n")

suppressMessages(library(data.table, quietly = TRUE))
suppressMessages(library(bayesplot, quietly = TRUE))
Expand Down Expand Up @@ -349,7 +349,7 @@ cat("\n ----------- plot estimated/observed attack rates ----------- \n")
da <- copy( artable[[1]] )

da <- subset(da, select=-c(L_est,L_obs))
da <- reshape2::melt(da, measure.vars=c('M_est','CL_est','CU_est','M_obs','CL_obs','CU_obs'))
da <- as.data.table( reshape2::melt(da, measure.vars=c('M_est','CL_est','CU_est','M_obs','CL_obs','CU_obs')) )
set(da, NULL, 'value', da[, as.numeric(value)/100])
da[, mtype:= gsub('est','Estimated',gsub('obs','Survey',gsub('^([A-Za-z]+)_([A-Za-z]+)$','\\2',variable)))]
da[, stat:= gsub('^([A-Za-z]+)_([A-Za-z]+)$','\\1',variable)]
Expand Down Expand Up @@ -379,4 +379,4 @@ for (i in 1:length(lags)) {
ggsave(file=paste0(outfile.base, "-prop_antibody_validation_lag",lags[i],".png"),g,w=7, h=10)
}

cat(" \n -------------------------------- \n \n completed post-processing-validate-prop_antibodys.R \n \n -------------------------------- \n")
cat(" \n -------------------------------- \n \n completed post-processing-summarise-antibody.R \n \n -------------------------------- \n")

0 comments on commit 2f98e51

Please sign in to comment.