Skip to content

Commit

Permalink
update inference to the new modifiers structure
Browse files Browse the repository at this point in the history
  • Loading branch information
shauntruelove committed Oct 11, 2023
1 parent 10d118b commit a6cae8c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 5 additions & 1 deletion flepimop/main_scripts/inference_main.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ config <- flepicommon::load_config(opt$config)
##If outcome scenarios are specified check their existence
outcome_modifiers_scenarios <- opt$outcome_modifiers_scenarios
if (all(outcome_modifiers_scenarios == "all")) {
outcome_modifiers_scenarios <- config$outcomes_modifiers$scenarios
if (!is.null(config$outcomes_modifiers$scenarios)){
outcome_modifiers_scenarios <- config$outcomes_modifiers$scenarios
} else {
outcome_modifiers_scenarios <- "all"
}
} else if (!(outcome_modifiers_scenarios %in% config$outcomes_modifiers$scenarios)){
message(paste("Invalid outcome scenario argument:[",paste(setdiff(outcome_modifiers_scenarios, config$outcome$scenarios)), "] did not match any of the named args in", paste(config$outcomes_modifiers$scenarios, collapse = ", "), "\n"))
quit("yes", status=1)
Expand Down
18 changes: 11 additions & 7 deletions flepimop/main_scripts/inference_slot.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ if (!dir.exists(data_dir)){
# Parse scenarios arguments
##If outcome scenarios are specified check their existence
outcome_modifiers_scenarios <- opt$outcome_modifiers_scenarios
if(all(outcome_modifiers_scenarios == "all")) {
outcome_modifiers_scenarios <- config$outcomes_modifiers$scenarios
if (all(outcome_modifiers_scenarios == "all")) {
if (!is.null(config$outcomes_modifiers$scenarios)){
outcome_modifiers_scenarios <- config$outcomes_modifiers$scenarios
} else {
outcome_modifiers_scenarios <- "all"
}
} else if (!(outcome_modifiers_scenarios %in% config$outcomes_modifiers$scenarios)){
message(paste("Invalid outcome scenario argument:[",paste(setdiff(outcome_modifiers_scenarios, config$outcome$scenarios)), "] did not match any of the named args in", paste(config$outcomes_modifiers$scenarios, collapse = ", "), "\n"))
quit("yes", status=1)
Expand Down Expand Up @@ -416,8 +420,8 @@ for(seir_modifiers_scenario in seir_modifiers_scenarios) {
global_likelihood_data <- arrow::read_parquet(first_global_files[['llik_filename']])

##Add initial perturbation sd values to parameter files----
initial_snpi <- inference::add_perturb_column_snpi(initial_snpi,config$seir_modifiers$settings)
initial_hnpi <- inference::add_perturb_column_hnpi(initial_hnpi,config$seir_modifiers$settings)
initial_snpi <- inference::add_perturb_column_snpi(initial_snpi,config$seir_modifiers$modifiers)
initial_hnpi <- inference::add_perturb_column_hnpi(initial_hnpi,config$outcomes_modifiers$modifiers)

#Need to write these parameters back to the SAME chimeric file since they have a new column now
arrow::write_parquet(initial_snpi,first_chimeric_files[['snpi_filename']])
Expand Down Expand Up @@ -472,10 +476,10 @@ for(seir_modifiers_scenario in seir_modifiers_scenarios) {
} else {
proposed_init <- initial_init
}
proposed_snpi <- inference::perturb_snpi(initial_snpi, config$seir_modifiers$settings)
proposed_hnpi <- inference::perturb_hnpi(initial_hnpi, config$seir_modifiers$settings)
proposed_snpi <- inference::perturb_snpi(initial_snpi, config$seir_modifiers$modifiers)
proposed_hnpi <- inference::perturb_hnpi(initial_hnpi, config$outcomes_modifiers$modifiers) # NOTE: no scenarios possible right now
proposed_spar <- initial_spar
proposed_hpar <- inference::perturb_hpar(initial_hpar, config$outcomes$settings[[outcome_modifiers_scenario]])
proposed_hpar <- inference::perturb_hpar(initial_hpar, config$outcomes$outcomes) # NOTE: no scenarios possible right now
if (!is.null(config$initial_conditions)){
proposed_init <- initial_init
}
Expand Down

0 comments on commit a6cae8c

Please sign in to comment.