diff --git a/resources/ResourceFile_HIV.xlsx b/resources/ResourceFile_HIV.xlsx index f76169e701..b2db25c898 100644 --- a/resources/ResourceFile_HIV.xlsx +++ b/resources/ResourceFile_HIV.xlsx @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:913d736db7717519270d61824a8855cbfd4d6e61a73b7ce51e2c3b7915b011ff -size 161597 +oid sha256:f57142efaf515d74f8290238ce1abad7b99871f9195623112892b3bb535bf634 +size 161721 diff --git a/src/scripts/hiv/projections_jan2023/analysis_logged_deviance.py b/src/scripts/hiv/projections_jan2023/analysis_logged_deviance.py index eca9f999bc..7a2af7fbed 100644 --- a/src/scripts/hiv/projections_jan2023/analysis_logged_deviance.py +++ b/src/scripts/hiv/projections_jan2023/analysis_logged_deviance.py @@ -34,8 +34,8 @@ # %% Run the simulation start_date = Date(2010, 1, 1) -end_date = Date(2014, 1, 1) -popsize = 1000 +end_date = Date(2022, 1, 1) +popsize = 5000 # scenario = 1 @@ -87,8 +87,8 @@ ) # set the scenario -# sim.modules["Hiv"].parameters["beta"] = 0.129671 -# sim.modules["Tb"].parameters["scaling_factor_WHO"] = 1.5 +sim.modules["Hiv"].parameters["do_scaleup"] = True +sim.modules["Hiv"].parameters["scaleup_start_year"] = 2019 # sim.modules["Tb"].parameters["scenario"] = scenario # sim.modules["Tb"].parameters["scenario_start_date"] = Date(2010, 1, 1) # sim.modules["Tb"].parameters["scenario_SI"] = "z" diff --git a/src/scripts/htm_scenario_analyses/analysis_htm_scaleup.py b/src/scripts/htm_scenario_analyses/analysis_htm_scaleup.py index a89231f670..beacb5e218 100644 --- a/src/scripts/htm_scenario_analyses/analysis_htm_scaleup.py +++ b/src/scripts/htm_scenario_analyses/analysis_htm_scaleup.py @@ -51,9 +51,9 @@ def __init__(self): super().__init__() self.seed = 0 self.start_date = Date(2010, 1, 1) - self.end_date = Date(2020, 1, 1) - self.pop_size = 75_000 - self.number_of_draws = 5 + self.end_date = Date(2025, 1, 1) + self.pop_size = 5_000 + self.number_of_draws = 2 self.runs_per_draw = 1 def log_configuration(self): @@ -86,7 +86,7 @@ def modules(self): ] def draw_parameters(self, draw_number, rng): - scaleup_start_year = 2012 + scaleup_start_year = 2019 return { 'Hiv': { diff --git a/src/scripts/htm_scenario_analyses/scenario_plots.py b/src/scripts/htm_scenario_analyses/scenario_plots.py index d14454ae13..c209c60f6e 100644 --- a/src/scripts/htm_scenario_analyses/scenario_plots.py +++ b/src/scripts/htm_scenario_analyses/scenario_plots.py @@ -23,6 +23,7 @@ datestamp = datetime.date.today().strftime("__%Y_%m_%d") outputspath = Path("./outputs") +# outputspath = Path("./outputs/t.mangal@imperial.ac.uk") # 0) Find results_folder associated with a given batch_file (and get most recent [-1]) @@ -32,7 +33,7 @@ make_graph_file_name = lambda stub: results_folder / f"{stub}.png" # noqa: E731 # look at one log (so can decide what to extract) -log = load_pickled_dataframes(results_folder) +log = load_pickled_dataframes(results_folder, draw=1) # get basic information about the results info = get_scenario_info(results_folder) @@ -55,14 +56,14 @@ def get_num_deaths_by_cause_label(_df): .size() -TARGET_PERIOD = (Date(2015, 1, 1), Date(2020, 1, 1)) +TARGET_PERIOD = (Date(2020, 1, 1), Date(2025, 1, 1)) num_deaths_by_cause_label = extract_results( results_folder, module='tlo.methods.demography', key='death', custom_generate_series=get_num_deaths_by_cause_label, - do_scaling=True + do_scaling=False ) @@ -103,9 +104,9 @@ def summarise_deaths_for_one_cause(results_folder, label): tb_deaths = summarise_deaths_for_one_cause(results_folder, 'TB (non-AIDS)') malaria_deaths = summarise_deaths_for_one_cause(results_folder, 'Malaria') -draw_labels = ['No scale-up', 'HIV, scale-up', 'TB scale-up', 'Malaria scale-up'] +draw_labels = ['No scale-up', 'HIV, scale-up', 'TB scale-up', 'Malaria scale-up', 'HTM scale-up'] -colors = sns.color_palette("Set1", 4) # Blue, Orange, Green, Red +colors = sns.color_palette("Set1", 5) # Blue, Orange, Green, Red # Create subplots @@ -116,19 +117,19 @@ def summarise_deaths_for_one_cause(results_folder, label): axs[0].plot(aids_deaths.index, aids_deaths[col], label=draw_labels[i], color=colors[i]) axs[0].set_title('HIV/AIDS') axs[0].legend() -axs[0].axvline(x=2015, color='gray', linestyle='--') +axs[0].axvline(x=2019, color='gray', linestyle='--') # Plot for df2 for i, col in enumerate(tb_deaths.columns): axs[1].plot(tb_deaths.index, tb_deaths[col], color=colors[i]) axs[1].set_title('TB') -axs[1].axvline(x=2015, color='gray', linestyle='--') +axs[1].axvline(x=2019, color='gray', linestyle='--') # Plot for df3 for i, col in enumerate(malaria_deaths.columns): axs[2].plot(malaria_deaths.index, malaria_deaths[col], color=colors[i]) axs[2].set_title('Malaria') -axs[2].axvline(x=2015, color='gray', linestyle='--') +axs[2].axvline(x=2019, color='gray', linestyle='--') for ax in axs: ax.set_xlabel('Years') diff --git a/src/tlo/methods/hiv.py b/src/tlo/methods/hiv.py index 4c4e5d9c14..d744c9d254 100644 --- a/src/tlo/methods/hiv.py +++ b/src/tlo/methods/hiv.py @@ -472,10 +472,13 @@ def read_parameters(self, data_folder): ) def pre_initialise_population(self): - """ - * Establish the Linear Models - * - """ + """Do things required before the population is created + * Build the LinearModels""" + self._build_linear_models() + + def _build_linear_models(self): + """Establish the Linear Models""" + p = self.parameters # ---- LINEAR MODELS ----- @@ -1099,42 +1102,41 @@ def initialise_simulation(self, sim): ) def update_parameters_for_program_scaleup(self): - p = self.parameters scaled_params = p["scaleup_parameters"] - if p["do_scaleup"]: + # scale-up HIV program + # reduce risk of HIV - applies to whole adult population + p["beta"] = p["beta"] * scaled_params["reduction_in_hiv_beta"] - # scale-up HIV program - # reduce risk of HIV - applies to whole adult population - p["beta"] = p["beta"] * scaled_params["reduction_in_hiv_beta"] + # increase PrEP coverage for FSW after HIV test + p["prob_prep_for_fsw_after_hiv_test"] = scaled_params["prob_prep_for_fsw_after_hiv_test"] - # increase PrEP coverage for FSW after HIV test - p["prob_prep_for_fsw_after_hiv_test"] = scaled_params["prob_prep_for_fsw_after_hiv_test"] + # prep poll for AGYW - target to the highest risk + # increase retention to 75% for FSW and AGYW + p["prob_prep_for_agyw"] = scaled_params["prob_prep_for_agyw"] + p["probability_of_being_retained_on_prep_every_3_months"] = scaled_params["probability_of_being_retained_on_prep_every_3_months"] - # prep poll for AGYW - target to the highest risk - # increase retention to 75% for FSW and AGYW - p["prob_prep_for_agyw"] = scaled_params["prob_prep_for_agyw"] - p["probability_of_being_retained_on_prep_every_3_months"] = scaled_params["probability_of_being_retained_on_prep_every_3_months"] + # perfect retention on ART + p["probability_of_being_retained_on_art_every_3_months"] = scaled_params["probability_of_being_retained_on_art_every_3_months"] - # increase probability of VMMC after hiv test - p["prob_circ_after_hiv_test"] = scaled_params["prob_circ_after_hiv_test"] + # increase probability of VMMC after hiv test + p["prob_circ_after_hiv_test"] = scaled_params["prob_circ_after_hiv_test"] - # increase testing/diagnosis rates, default 2020 0.03/0.25 -> 93% dx - p["hiv_testing_rates"]["annual_testing_rate_children"] = scaled_params["annual_testing_rate_children"] - p["hiv_testing_rates"]["annual_testing_rate_adults"] = scaled_params["annual_testing_rate_adults"] + # increase testing/diagnosis rates, default 2020 0.03/0.25 -> 93% dx + p["hiv_testing_rates"]["annual_testing_rate_adults"] = scaled_params["annual_testing_rate_adults"] - # ANC testing - value for mothers and infants testing - p["prob_hiv_test_at_anc_or_delivery"] = scaled_params["prob_hiv_test_at_anc_or_delivery"] - p["prob_hiv_test_for_newborn_infant"] = scaled_params["prob_hiv_test_for_newborn_infant"] + # ANC testing - value for mothers and infants testing + p["prob_hiv_test_at_anc_or_delivery"] = scaled_params["prob_hiv_test_at_anc_or_delivery"] + p["prob_hiv_test_for_newborn_infant"] = scaled_params["prob_hiv_test_for_newborn_infant"] - # prob ART start if dx, this is already 95% at 2020 - p["prob_start_art_after_hiv_test"] = scaled_params["prob_start_art_after_hiv_test"] + # viral suppression rates + # adults already at 95% by 2020 + # change all column values + p["prob_start_art_or_vs"]["virally_suppressed_on_art"] = scaled_params["virally_suppressed_on_art"] - # viral suppression rates - # adults already at 95% by 2020 - # change all column values - p["prob_start_art_or_vs"]["virally_suppressed_on_art"] = scaled_params["virally_suppressed_on_art"] + # update exising linear models to use new scaled-up paramters + self._build_linear_models() def on_birth(self, mother_id, child_id): """ diff --git a/src/tlo/methods/malaria.py b/src/tlo/methods/malaria.py index 8c451b62d0..a5e9738a99 100644 --- a/src/tlo/methods/malaria.py +++ b/src/tlo/methods/malaria.py @@ -327,13 +327,16 @@ def read_parameters(self, data_folder): ) def pre_initialise_population(self): - """ - * Establish the Linear Models + """Do things required before the population is created + * Build the LinearModels""" + self._build_linear_models() + + def _build_linear_models(self): + """Establish the Linear Models if HIV is registered, the conditional predictors will apply otherwise only IPTp will affect risk of clinical/severe malaria """ - p = self.parameters # ---- LINEAR MODELS ----- @@ -656,52 +659,52 @@ def initialise_simulation(self, sim): ) def update_parameters_for_program_scaleup(self): - p = self.parameters scaled_params = p["scaleup_parameters"] - if p["do_scaleup"]: + # scale-up malaria program + # increase testing + # prob_malaria_case_tests=0.4 default + p["prob_malaria_case_tests"] = scaled_params["prob_malaria_case_tests"] - # scale-up malaria program - # increase testing - # prob_malaria_case_tests=0.4 default - p["prob_malaria_case_tests"] = scaled_params["prob_malaria_case_tests"] + # gen pop testing rates + # annual Rate_rdt_testing=0.64 at 2023 + p["rdt_testing_rates"]["Rate_rdt_testing"] = scaled_params["rdt_testing_rates"] - # gen pop testing rates - # annual Rate_rdt_testing=0.64 at 2023 - p["rdt_testing_rates"]["Rate_rdt_testing"] = scaled_params["rdt_testing_rates"] + # treatment reaches XX + # no default between testing and treatment, governed by tx availability - # treatment reaches XX - # no default between testing and treatment, governed by tx availability + # coverage IPTp reaches XX + # given during ANC visits and MalariaIPTp Event which selects ALL eligible women - # coverage IPTp reaches XX - # given during ANC visits and MalariaIPTp Event which selects ALL eligible women + # treatment success reaches 1 - default is currently 1 also + p["prob_of_treatment_success"] = scaled_params["prob_of_treatment_success"] - # treatment success reaches 1 - default is currently 1 also - p["prob_of_treatment_success"] = scaled_params["prob_of_treatment_success"] + # bednet and ITN coverage + # set IRS for 4 high-risk districts + # lookup table created in malaria read_parameters + # produces self.itn_irs called by malaria poll to draw incidence + # need to overwrite this + highrisk_distr_num = p["highrisk_districts"]["district_num"] - # bednet and ITN coverage - # set IRS for 4 high-risk districts - # lookup table created in malaria read_parameters - # produces self.itn_irs called by malaria poll to draw incidence - # need to overwrite this - highrisk_distr_num = p["highrisk_districts"]["district_num"] + # Find indices where District_Num is in highrisk_distr_num + mask = self.itn_irs['irs_rate'].index.get_level_values('District_Num').isin( + highrisk_distr_num) - # Find indices where District_Num is in highrisk_distr_num - mask = self.itn_irs['irs_rate'].index.get_level_values('District_Num').isin( - highrisk_distr_num) + # IRS values can be 0 or 0.8 - no other value in lookup table + self.itn_irs['irs_rate'].loc[mask] = scaled_params["irs_district"] - # IRS values can be 0 or 0.8 - no other value in lookup table - self.itn_irs['irs_rate'].loc[mask] = scaled_params["irs_district"] + # set ITN for all districts + # Set these values to 0.7 - this is the max value possible in lookup table + # equivalent to 0.7 of all pop sleeping under bednet + # household coverage could be 100%, but not everyone in household sleeping under bednet + self.itn_irs['itn_rate'] = scaled_params["itn_district"] - # set ITN for all districts - # Set these values to 0.7 - this is the max value possible in lookup table - # equivalent to 0.7 of all pop sleeping under bednet - # household coverage could be 100%, but not everyone in household sleeping under bednet - self.itn_irs['itn_rate'] = scaled_params["itn_district"] + # itn rates for 2019 onwards + p["itn"] = scaled_params["itn"] - # itn rates for 2019 onwards - p["itn"] = scaled_params["itn"] + # update exising linear models to use new scaled-up parameters + self._build_linear_models() def on_birth(self, mother_id, child_id): df = self.sim.population.props diff --git a/src/tlo/methods/tb.py b/src/tlo/methods/tb.py index 5f87bcd261..3392d90b62 100644 --- a/src/tlo/methods/tb.py +++ b/src/tlo/methods/tb.py @@ -470,9 +470,13 @@ def read_parameters(self, data_folder): ) def pre_initialise_population(self): - """ - * Establish the Linear Models - """ + """Do things required before the population is created + * Build the LinearModels""" + self._build_linear_models() + + def _build_linear_models(self): + """Establish the Linear Models""" + p = self.parameters # risk of active tb @@ -885,29 +889,29 @@ def initialise_simulation(self, sim): ) def update_parameters_for_program_scaleup(self): - p = self.parameters scaled_params = p["scaleup_parameters"] - if p["do_scaleup"]: + # scale-up TB program + # use NTP treatment rates + p["rate_testing_active_tb"]["treatment_coverage"] = scaled_params["tb_treatment_coverage"] - # scale-up TB program - # use NTP treatment rates - p["rate_testing_active_tb"]["treatment_coverage"] = scaled_params["tb_treatment_coverage"] + # increase tb treatment success rates + p["prob_tx_success_ds"] = scaled_params["tb_prob_tx_success_ds"] + p["prob_tx_success_mdr"] = scaled_params["tb_prob_tx_success_mdr"] + p["prob_tx_success_0_4"] = scaled_params["tb_prob_tx_success_0_4"] + p["prob_tx_success_5_14"] = scaled_params["tb_prob_tx_success_5_14"] - # increase tb treatment success rates - p["prob_tx_success_ds"] = scaled_params["tb_prob_tx_success_ds"] - p["prob_tx_success_mdr"] = scaled_params["tb_prob_tx_success_mdr"] - p["prob_tx_success_0_4"] = scaled_params["tb_prob_tx_success_0_4"] - p["prob_tx_success_5_14"] = scaled_params["tb_prob_tx_success_5_14"] + # change first-line testing for TB to xpert + p["first_line_test"] = scaled_params["first_line_test"] + p["second_line_test"] = scaled_params["second_line_test"] - # change first-line testing for TB to xpert - p["first_line_test"] = scaled_params["first_line_test"] - p["second_line_test"] = scaled_params["second_line_test"] + # increase coverage of IPT + p["ipt_coverage"]["coverage_plhiv"] = scaled_params["ipt_coverage_plhiv"] + p["ipt_coverage"]["coverage_paediatric"] = scaled_params["ipt_coverage_paediatric"] - # increase coverage of IPT - p["ipt_coverage"]["coverage_plhiv"] = scaled_params["ipt_coverage_plhiv"] - p["ipt_coverage"]["coverage_paediatric"] = scaled_params["ipt_coverage_paediatric"] + # update exising linear models to use new scaled-up paramters + self._build_linear_models() def on_birth(self, mother_id, child_id): """Initialise properties for a newborn individual