Skip to content

Commit 0508e04

Browse files
authored
Albright/mic-5889/use-birth-exposure-key (#513)
Albright/mic-5889/use-birth-exposure-key Use birth exposure key for LBWSG components - *Category*: Feature - *JIRA issue*: https://jira.ihme.washington.edu/browse/MIC-5889 Changes and notes -Use birth exposure key from artifact for LBWSG components ### Testing <!-- Details on how code was verified, any unit tests local for the repo, regression testing, etc. At a minimum, this should include an integration test for a framework change. Consider: plots, images, (small) csv file. -->
1 parent 6b0e0b3 commit 0508e04

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**4.0.0 - 03/17/25**
2+
3+
- Feature: Use birth exposure artifact key for LBWSG components
4+
15
**3.2.2 - 2/21/25**
26

37
- Bugfix: Use relative risk data to get age intervals for LBWSGRiskEffect

src/vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ def get_exposure_column_name(axis: str) -> str:
202202
@property
203203
def configuration_defaults(self) -> dict[str, Any]:
204204
configuration_defaults = super().configuration_defaults
205+
configuration_defaults[self.name]["data_sources"][
206+
"exposure"
207+
] = f"{self.risk}.birth_exposure"
205208
configuration_defaults[self.name]["distribution_type"] = "lbwsg"
206209
return configuration_defaults
207210

tests/risks/test_low_birth_weight_and_short_gestation.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ def test_parsing_lbwsg_descriptions(description, expected_weight_values, expecte
4141
assert age_interval.right == expected_age_values[1]
4242

4343

44-
def test_lbwsg_risk_effect_rr_pipeline(
45-
base_config, base_plugins, mocker, mock_rr_interpolators
46-
):
44+
def test_lbwsg_risk_effect_rr_pipeline(base_config, base_plugins, mock_rr_interpolators):
4745

4846
risk = LBWSGRisk()
4947
lbwsg_effect = LBWSGRiskEffect("cause.test_cause.cause_specific_mortality_rate")
@@ -63,7 +61,7 @@ def test_lbwsg_risk_effect_rr_pipeline(
6361

6462
# Add data dict to add to artifact
6563
data = {
66-
f"{risk.name}.exposure": exposure,
64+
f"{risk.name}.birth_exposure": exposure,
6765
f"{risk.name}.relative_risk": rr_data,
6866
f"{risk.name}.population_attributable_fraction": 0,
6967
f"{risk.name}.categories": categories,
@@ -122,6 +120,59 @@ def map_age_groups(value):
122120
assert (actual_rr == 1.0).all()
123121

124122

123+
def test_use_birth_exposure(base_config, base_plugins, mock_rr_interpolators):
124+
risk = LBWSGRisk()
125+
lbwsg_effect = LBWSGRiskEffect("cause.test_cause.cause_specific_mortality_rate")
126+
127+
# Add mock data to artifact
128+
categories = {
129+
"cat81": "Neonatal preterm and LBWSG (estimation years) - [28, 30) wks, [2500, 3000) g",
130+
"cat82": "Neonatal preterm and LBWSG (estimation years) - [28, 30) wks, [3000, 3500) g",
131+
}
132+
# Create exposure with matching demograph index as age_bins
133+
age_bins = make_age_bins()
134+
ages = age_bins.drop(columns="age_group_name")
135+
# Have to match age bins and rr data to make age intervals
136+
rr_data = make_categorical_data(ages)
137+
# Format birth exposure data
138+
exposure = pd.DataFrame(
139+
{
140+
"sex": ["Male", "Female", "Male", "Female"],
141+
"year_start": [2021, 2021, 2021, 2021],
142+
"year_end": [2022, 2022, 2022, 2022],
143+
"parameter": ["cat81", "cat81", "cat82", "cat82"],
144+
"value": [0.75, 0.75, 0.25, 0.25],
145+
}
146+
)
147+
148+
# Add data dict to add to artifact
149+
data = {
150+
f"{risk.name}.birth_exposure": exposure,
151+
f"{risk.name}.relative_risk": rr_data,
152+
f"{risk.name}.population_attributable_fraction": 0,
153+
f"{risk.name}.categories": categories,
154+
f"{risk.name}.relative_risk_interpolator": mock_rr_interpolators,
155+
}
156+
157+
# Only have neontal age groups
158+
age_start = 0.0
159+
age_end = 1.0
160+
base_config.update(
161+
{
162+
"population": {
163+
"initialization_age_start": age_start,
164+
"initialization_age_max": age_end,
165+
}
166+
}
167+
)
168+
sim = _setup_risk_effect_simulation(base_config, base_plugins, risk, lbwsg_effect, data)
169+
pop = sim.get_population()
170+
171+
# Assert LBWSG birth exposure columns were created
172+
assert "birth_weight_exposure" in pop.columns
173+
assert "gestational_age_exposure" in pop.columns
174+
175+
125176
def make_categorical_data(data: pd.DataFrame) -> pd.DataFrame:
126177
# Takes age gropus and adds sex, years, categories, and values
127178
dfs = []

0 commit comments

Comments
 (0)