diff --git a/batch/inference_job_launcher.py b/batch/inference_job_launcher.py index e3eee5b9d..b9a27c17e 100755 --- a/batch/inference_job_launcher.py +++ b/batch/inference_job_launcher.py @@ -431,7 +431,7 @@ def autodetect_params(config, data_path, *, num_jobs=None, sims_per_job=None, nu print(f"Setting number of blocks to {num_blocks} [via num_blocks (-k) argument]") print(f"Setting sims per job to {sims_per_job} [via {iterations_per_slot} iterations_per_slot in config]") else: - if config["data_path"]: + if "data_path" in config: raise ValueError("The config has a data_path section. This is no longer supported.") geodata_fname = pathlib.Path(data_path) / config["subpop_setup"]["geodata"] with open(geodata_fname) as geodata_fp: diff --git a/flepimop/R_packages/flepiconfig/R/create_config_data.R b/flepimop/R_packages/flepiconfig/R/create_config_data.R index 187d5cba7..5fa371e36 100644 --- a/flepimop/R_packages/flepiconfig/R/create_config_data.R +++ b/flepimop/R_packages/flepiconfig/R/create_config_data.R @@ -30,7 +30,7 @@ set_npi_params <- function(npi_name = "waning_npi", param_name = "epsilon", npi_category = "universal_npi", affected_subpops = "all", - spatial_groups = NULL, + subpop_groups = NULL, sim_start_date=as.Date("2020-01-01"), sim_end_date=Sys.Date()+60, modifier_method = "SinglePeriodModifier", @@ -41,8 +41,8 @@ set_npi_params <- function(npi_name = "waning_npi", p_mean = 0, p_sd = 0.05, p_a = -1, p_b = 1 ){ # check that universal npi was implemented correctly - if (npi_category == "universal_npi" & is.null(spatial_groups)){ - spatial_groups <- "all" + if (npi_category == "universal_npi" & is.null(subpop_groups)){ + subpop_groups <- "all" } sim_start_date <- as.Date(sim_start_date) @@ -50,7 +50,7 @@ set_npi_params <- function(npi_name = "waning_npi", local_var <- dplyr::tibble(USPS = "", subpop = affected_subpops, - spatial_groups = spatial_groups, + subpop_groups = subpop_groups, name = npi_name, type = "transmission", category = npi_category, @@ -71,7 +71,7 @@ set_npi_params <- function(npi_name = "waning_npi", pert_b = p_b) %>% dplyr::mutate(pert_dist = ifelse(inference, as.character(pert_dist), NA_character_), dplyr::across(pert_mean:pert_b, ~ifelse(inference, as.numeric(.x), NA_real_))) %>% - dplyr::select(USPS, subpop, spatial_groups, start_date, end_date, name, modifier_method, type, category, parameter, baseline_scenario, + dplyr::select(USPS, subpop, subpop_groups, start_date, end_date, name, modifier_method, type, category, parameter, baseline_scenario, tidyselect::starts_with("value_"), tidyselect::starts_with("pert_")) return(local_var) diff --git a/flepimop/R_packages/flepiconfig/R/yaml_utils.R b/flepimop/R_packages/flepiconfig/R/yaml_utils.R index 7144313f5..24e97b78a 100644 --- a/flepimop/R_packages/flepiconfig/R/yaml_utils.R +++ b/flepimop/R_packages/flepiconfig/R/yaml_utils.R @@ -88,7 +88,7 @@ collapse_intervention<- function(dat){ dplyr::group_by(dplyr::across(-period)) %>% dplyr::summarize(period = paste0(period, collapse="\n ")) - if (exists("mtr$spatial_groups") && (!all(is.na(mtr$spatial_groups)) & !all(is.null(mtr$spatial_groups)))) { + if (exists("mtr$subpop_groups") && (!all(is.na(mtr$subpop_groups)) & !all(is.null(mtr$subpop_groups)))) { mtr <- mtr %>% dplyr::group_by(dplyr::across(-subpop)) %>% @@ -1335,9 +1335,17 @@ print_outcomes <- function (resume_modifier = NULL, incidC_pert <- "" pert_repeat <- prod(compartment_tract_length[-1], na.rm = TRUE) - variant_strata = compartment_tract_list$variant_strata - vaccine_strata = compartment_tract_list$vaccine_strata - age_strata = compartment_tract_list$age_strata + variant_strata = `$`(compartment_tract_list, 'variant') + vaccine_strata = `$`(compartment_tract_list, 'vacc') + age_strata = `$`(compartment_tract_list, 'age') + strata_names <- names(compartment_tract_list) + inf_strata_name <- strata_names[grepl('inf', strata_names)] + variant_strata_name <- strata_names[grepl('var', strata_names)] + vacc_strata_name <- strata_names[grepl('vacc', strata_names)] + age_strata_name <- strata_names[grepl('age_', strata_names)] +# variant_strata = compartment_tract_list$variant_strata +# vaccine_strata = compartment_tract_list$vaccine_strata +# age_strata = compartment_tract_list$age_strata for (i in 1:pert_repeat) { if (incidC_perturbation) { @@ -1405,10 +1413,10 @@ print_outcomes <- function (resume_modifier = NULL, incidH <- paste0(incidH, " incidH_", outcomes_base_data$variant_strata[i], ":\n", " source:\n", " incidence:\n", - " infection_stage: \"I1\"\n", - " vaccination_strata: \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", - " variant_strata: \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", - " age_strata: \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", + " ", inf_strata_name, ": \"I1\"\n", + " ", vacc_strata_name, ": \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", + " ", variant_strata_name, ": \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", + " ", age_strata_name, ": \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", " probability:\n", if ("incidH" %in% intervention_params) paste0(" modifier_parameter: \"", incidItoHparam, "\"\n"), print_value(value_dist = incidH_prob_dist, @@ -1437,10 +1445,10 @@ print_outcomes <- function (resume_modifier = NULL, incidD <- paste0(incidD, " incidD_", outcomes_base_data$variant_strata[i], ":\n", " source:\n", " incidence:\n", - " infection_stage: \"I1\"\n", - " vaccination_strata: \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", - " variant_strata: \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", - " age_strata: \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", + " ", inf_strata_name, ": \"I1\"\n", + " ", vacc_strata_name, ": \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", + " ", variant_strata_name, ": \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", + " ", age_strata_name, ": \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", " probability:\n", if ("incidD" %in% intervention_params) paste0(" modifier_parameter: \"", incidItoDparam, "\"\n"), print_value(value_dist = incidD_prob_dist, @@ -1470,10 +1478,10 @@ print_outcomes <- function (resume_modifier = NULL, " incidC_", outcomes_base_data$variant_strata[i], ":\n", " source:\n", " incidence:\n", - " infection_stage: \"I1\"\n", - " vaccination_strata: \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", - " variant_strata: \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", - " age_strata: \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", + " ", inf_strata_name, ": \"I1\"\n", + " ", vacc_strata_name, ": \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", + " ", variant_strata_name, ": \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", + " ", age_strata_name, ": \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", " probability:\n", if ("incidC" %in% intervention_params) paste0(" modifier_parameter: \"", incidItoCparam, "\"\n"), print_value(value_dist = incidC_prob_dist, @@ -1492,10 +1500,10 @@ print_outcomes <- function (resume_modifier = NULL, " incidI_", outcomes_base_data$variant_strata[i], ":\n", " source:\n", " incidence:\n", - " infection_stage: \"I1\"\n", - " vaccination_strata: \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", - " variant_strata: \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", - " age_strata: \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", + " ", inf_strata_name, ": \"I1\"\n", + " ", vacc_strata_name, ": \"", paste0(outcomes_base_data$vacc[i], collapse = "\", \""), "\"\n", + " ", variant_strata_name, ": \"", paste0(outcomes_base_data$variant[i], collapse = "\", \""), "\"\n", + " ", age_strata_name, ": \"", paste0(outcomes_base_data$age_strata[i]), "\"\n", " probability:\n", if("incidI" %in% intervention_params) paste0(' modifier_parameter: "incidI_total"\n'), print_value(value_dist = "fixed",