diff --git a/src/vivarium_gates_mncnh/constants/data_keys.py b/src/vivarium_gates_mncnh/constants/data_keys.py index a1282bc..aa74151 100644 --- a/src/vivarium_gates_mncnh/constants/data_keys.py +++ b/src/vivarium_gates_mncnh/constants/data_keys.py @@ -15,6 +15,7 @@ class __Population(NamedTuple): AGE_BINS: str = "population.age_bins" DEMOGRAPHY: str = "population.demographic_dimensions" TMRLE: str = "population.theoretical_minimum_risk_life_expectancy" + SCALING_FACTOR: str = "population.scaling_factor" @property def name(self): diff --git a/src/vivarium_gates_mncnh/data/loader.py b/src/vivarium_gates_mncnh/data/loader.py index ed06d16..0286f77 100644 --- a/src/vivarium_gates_mncnh/data/loader.py +++ b/src/vivarium_gates_mncnh/data/loader.py @@ -54,6 +54,7 @@ def get_data( data_keys.POPULATION.AGE_BINS: load_age_bins, data_keys.POPULATION.DEMOGRAPHY: load_demographic_dimensions, data_keys.POPULATION.TMRLE: load_theoretical_minimum_risk_life_expectancy, + data_keys.POPULATION.SCALING_FACTOR: load_scaling_factor, # data_keys.POPULATION.ACMR: load_standard_data, # TODO - add appropriate mappings data_keys.PREGNANCY.ASFR: load_asfr, @@ -170,6 +171,8 @@ def _load_em_from_meid(location, meid, measure): # TODO - add project-specific data functions here + + def load_asfr( key: str, location: str, years: Optional[Union[int, str, List[int]]] = None ) -> pd.DataFrame: @@ -210,6 +213,34 @@ def load_raw_incidence_data( return vi_utils.sort_hierarchical_data(data).droplevel("location") +def load_scaling_factor( + key: str, location: str, years: Optional[Union[int, str, List[int]]] = None +) -> pd.DataFrame: + + incidence_c995 = get_data( + data_keys.PREGNANCY.RAW_INCIDENCE_RATE_MISCARRIAGE, location, years + ).reset_index() + incidence_c374 = get_data( + data_keys.PREGNANCY.RAW_INCIDENCE_RATE_ECTOPIC, location, years + ).reset_index() + asfr = get_data(data_keys.PREGNANCY.ASFR, location).reset_index() + sbr = get_data(data_keys.PREGNANCY.SBR, location).reset_index() + + asfr = asfr.set_index(metadata.ARTIFACT_INDEX_COLUMNS) + incidence_c995 = incidence_c995.set_index(metadata.ARTIFACT_INDEX_COLUMNS) + incidence_c374 = incidence_c374.set_index(metadata.ARTIFACT_INDEX_COLUMNS) + sbr = ( + sbr.set_index("year_start") + .drop(columns=["year_end"]) + .reindex(asfr.index, level="year_start") + ) + + # Calculate pregnancy incidence + preg_inc = asfr + asfr.multiply(sbr["value"], axis=0) + incidence_c995 + incidence_c374 + + return preg_inc + + def load_lbwsg_exposure( key: str, location: str, years: Optional[Union[int, str, list[int]]] = None ) -> pd.DataFrame: diff --git a/src/vivarium_gates_mncnh/model_specifications/branches/scenarios.yaml b/src/vivarium_gates_mncnh/model_specifications/branches/scenarios.yaml index 06926da..605bc0d 100644 --- a/src/vivarium_gates_mncnh/model_specifications/branches/scenarios.yaml +++ b/src/vivarium_gates_mncnh/model_specifications/branches/scenarios.yaml @@ -1,5 +1,5 @@ input_draw_count: 10 -random_seed_count: 5 +random_seed_count: 10 branches: # TODO change to name of intervention diff --git a/src/vivarium_gates_mncnh/model_specifications/model_spec.yaml b/src/vivarium_gates_mncnh/model_specifications/model_spec.yaml index cfabc07..a5dc4d6 100644 --- a/src/vivarium_gates_mncnh/model_specifications/model_spec.yaml +++ b/src/vivarium_gates_mncnh/model_specifications/model_spec.yaml @@ -7,7 +7,7 @@ plugins: components: vivarium_public_health: population: - - BasePopulation() + - ScaledPopulation("population.scaling_factor") vivarium_gates_mncnh: components: @@ -20,7 +20,7 @@ components: configuration: input_data: input_draw_number: 0 - artifact_path: "/mnt/team/simulation_science/pub/models/vivarium_gates_mncnh/artifacts/anc/ethiopia.hdf" + artifact_path: "/mnt/team/simulation_science/pub/models/vivarium_gates_mncnh/artifacts/anc/pakistan.hdf" interpolation: order: 0 extrapolate: True