| """Generate synthetic asbestos exposure & mesothelioma dataset for SSA. |
| |
| Research-based parameterization: |
| - WHO Africa: Asbestos use continues despite warnings; used in roofing, |
| insulation, cement pipes, brake linings across SSA. |
| - WHO Fact Sheet: Asbestos causes lung/larynx/ovary cancer, mesothelioma, |
| asbestosis. All forms carcinogenic (IARC Group 1). |
| - South Africa: Global leader in asbestos production; crocidolite/amosite/ |
| chrysotile all mined. Wagner (1960) discovered mesothelioma link. |
| - PMC1522094: Social production of asbestos-related disease in SA; |
| asbestosis, lung cancer, mesothelioma since early 1900s. |
| - PMC12573932 (GBD 2021): Eastern SSA saw substantial increases in lung |
| cancer from occupational asbestos exposure. |
| - SA banned asbestos mining in 2002; many SSA countries still use. |
| - Latency period: 20-50 years from exposure to mesothelioma. |
| - Mesothelioma mortality rates lower than expected in SA due to HIV |
| reducing life expectancy (PubMed 21422006). |
| """ |
|
|
| from __future__ import annotations |
|
|
| from pathlib import Path |
|
|
| import numpy as np |
| import pandas as pd |
|
|
| SEED = 42 |
| N_PER_SCENARIO = 10_000 |
|
|
| YEAR_RANGE = np.arange(2010, 2025) |
| YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE)) |
| YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum() |
|
|
| SCENARIOS = { |
| |
| "former_mining_community": { |
| "setting_probs": {"rural_mining": 0.50, "peri_urban": 0.30, "urban": 0.20}, |
| "exposure_probs": {"mining_direct": 0.30, "mining_environmental": 0.25, |
| "construction": 0.15, "roofing_materials": 0.15, |
| "household_exposure": 0.10, "brake_lining": 0.05}, |
| "fibre_type_probs": {"crocidolite": 0.35, "amosite": 0.25, "chrysotile": 0.30, "mixed": 0.10}, |
| "exposure_intensity_mean": 3.5, |
| "exposure_years_mean": 15, |
| "mesothelioma_rate": 0.008, |
| "asbestosis_prev": 0.12, |
| "lung_cancer_rate": 0.005, |
| "ban_in_place": 0.70, |
| "medical_surveillance": 0.15, |
| }, |
| |
| "urban_construction": { |
| "setting_probs": {"urban": 0.45, "peri_urban": 0.35, "industrial": 0.20}, |
| "exposure_probs": {"construction": 0.30, "roofing_materials": 0.25, |
| "demolition": 0.15, "insulation": 0.10, |
| "household_exposure": 0.10, "brake_lining": 0.10}, |
| "fibre_type_probs": {"chrysotile": 0.55, "amosite": 0.15, "crocidolite": 0.10, "mixed": 0.20}, |
| "exposure_intensity_mean": 1.5, |
| "exposure_years_mean": 10, |
| "mesothelioma_rate": 0.003, |
| "asbestosis_prev": 0.06, |
| "lung_cancer_rate": 0.003, |
| "ban_in_place": 0.30, |
| "medical_surveillance": 0.05, |
| }, |
| |
| "rural_asbestos_roofing": { |
| "setting_probs": {"rural": 0.55, "peri_urban": 0.30, "urban": 0.15}, |
| "exposure_probs": {"roofing_materials": 0.40, "household_exposure": 0.25, |
| "water_pipes": 0.10, "construction": 0.10, |
| "environmental": 0.10, "brake_lining": 0.05}, |
| "fibre_type_probs": {"chrysotile": 0.60, "mixed": 0.20, "amosite": 0.10, "crocidolite": 0.10}, |
| "exposure_intensity_mean": 0.5, |
| "exposure_years_mean": 20, |
| "mesothelioma_rate": 0.002, |
| "asbestosis_prev": 0.03, |
| "lung_cancer_rate": 0.002, |
| "ban_in_place": 0.15, |
| "medical_surveillance": 0.02, |
| }, |
| } |
|
|
| SCENARIO_FILES = { |
| "former_mining_community": "asbestos_mining_community.csv", |
| "urban_construction": "asbestos_urban_construction.csv", |
| "rural_asbestos_roofing": "asbestos_rural_roofing.csv", |
| } |
|
|
|
|
| def _choice(rng, prob_map): |
| keys = list(prob_map.keys()) |
| weights = np.array(list(prob_map.values()), dtype=float) |
| weights = weights / weights.sum() |
| return rng.choice(keys, p=weights) |
|
|
|
|
| def _simulate_scenario(name, params, seed): |
| rng = np.random.default_rng(seed) |
| records = [] |
|
|
| for idx in range(N_PER_SCENARIO): |
| year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS)) |
| setting = _choice(rng, params["setting_probs"]) |
| age = int(np.clip(rng.normal(45, 15), 18, 80)) |
| sex = rng.choice(["male", "female"], p=[0.65, 0.35]) |
|
|
| exposure_type = _choice(rng, params["exposure_probs"]) |
| fibre_type = _choice(rng, params["fibre_type_probs"]) |
| is_occupational = int(exposure_type in ("mining_direct", "construction", "demolition", "brake_lining")) |
| is_environmental = int(exposure_type in ("mining_environmental", "household_exposure", |
| "roofing_materials", "environmental", "water_pipes")) |
|
|
| exposure_years = int(np.clip( |
| rng.normal(params["exposure_years_mean"], 8), 0, 45)) |
| exposure_intensity = float(np.clip( |
| rng.lognormal(np.log(max(params["exposure_intensity_mean"], 0.1)), 0.8), |
| 0.01, 50)) |
| if not is_occupational: |
| exposure_intensity *= 0.2 |
|
|
| cumulative_exposure = float(exposure_intensity * exposure_years) |
| latency_years = int(np.clip(rng.normal(30, 10), 10, 50)) |
| time_since_first_exposure = int(np.clip(rng.normal(20, 10), 0, 50)) |
|
|
| ppe_use = int(is_occupational and rng.random() < 0.10) |
| if ppe_use: |
| exposure_intensity *= 0.3 |
|
|
| |
| potency = {"crocidolite": 2.0, "amosite": 1.5, "chrysotile": 1.0, "mixed": 1.3} |
| risk_mult = cumulative_exposure * potency.get(fibre_type, 1.0) / 20 |
|
|
| |
| |
| mesothelioma = int(time_since_first_exposure >= 15 and rng.random() < np.clip( |
| params["mesothelioma_rate"] * risk_mult, 0, 0.05)) |
| mesothelioma_type = rng.choice(["pleural", "peritoneal"], p=[0.85, 0.15]) if mesothelioma else "none" |
|
|
| |
| asbestosis = int(exposure_years >= 5 and rng.random() < np.clip( |
| params["asbestosis_prev"] * risk_mult, 0, 0.30)) |
|
|
| |
| lung_cancer = int(age >= 40 and rng.random() < np.clip( |
| params["lung_cancer_rate"] * risk_mult, 0, 0.03)) |
| smoking = int(rng.random() < 0.15) |
| if smoking: |
| lung_cancer = int(rng.random() < np.clip( |
| params["lung_cancer_rate"] * risk_mult * 5, 0, 0.10)) |
|
|
| |
| pleural_plaques = int(exposure_years >= 10 and rng.random() < np.clip( |
| 0.10 * risk_mult, 0, 0.40)) |
| pleural_effusion = int(pleural_plaques and rng.random() < 0.10) |
|
|
| |
| dyspnoea = int(rng.random() < np.clip(0.10 + risk_mult * 0.05, 0, 0.35)) |
| cough_chronic = int(rng.random() < np.clip(0.08 + risk_mult * 0.04, 0, 0.30)) |
| reduced_fvc = int(asbestosis or rng.random() < np.clip(risk_mult * 0.03, 0, 0.15)) |
|
|
| any_asbestos_disease = int(mesothelioma or asbestosis or lung_cancer or pleural_plaques) |
|
|
| |
| ban_in_place = int(rng.random() < params["ban_in_place"]) |
| medical_surveillance = int(rng.random() < params["medical_surveillance"]) |
| compensation_claimed = int(any_asbestos_disease and rng.random() < 0.05) |
| chest_xray_done = int(rng.random() < 0.10) |
|
|
| |
| hiv_positive = int(rng.random() < 0.12) |
| died = int((mesothelioma and rng.random() < 0.85) or |
| (lung_cancer and rng.random() < 0.70)) |
|
|
| record = { |
| "record_id": f"{name[:3].upper()}-{idx:05d}", |
| "scenario": name, |
| "year": year, |
| "setting": setting, |
| "age": age, |
| "sex": sex, |
| "exposure_type": exposure_type, |
| "fibre_type": fibre_type, |
| "is_occupational": is_occupational, |
| "is_environmental": is_environmental, |
| "exposure_years": exposure_years, |
| "exposure_intensity_f_mL": round(exposure_intensity, 2), |
| "cumulative_exposure": round(cumulative_exposure, 1), |
| "latency_years": latency_years, |
| "time_since_first_exposure": time_since_first_exposure, |
| "ppe_use": ppe_use, |
| "smoking": smoking, |
| "mesothelioma": mesothelioma, |
| "mesothelioma_type": mesothelioma_type, |
| "asbestosis": asbestosis, |
| "lung_cancer": lung_cancer, |
| "pleural_plaques": pleural_plaques, |
| "pleural_effusion": pleural_effusion, |
| "dyspnoea": dyspnoea, |
| "cough_chronic": cough_chronic, |
| "reduced_fvc": reduced_fvc, |
| "any_asbestos_disease": any_asbestos_disease, |
| "ban_in_place": ban_in_place, |
| "medical_surveillance": medical_surveillance, |
| "compensation_claimed": compensation_claimed, |
| "chest_xray_done": chest_xray_done, |
| "hiv_positive": hiv_positive, |
| "died": died, |
| } |
| records.append(record) |
|
|
| return pd.DataFrame(records) |
|
|
|
|
| def main(): |
| output_dir = Path("data") |
| output_dir.mkdir(parents=True, exist_ok=True) |
| for idx, (name, params) in enumerate(SCENARIOS.items()): |
| df = _simulate_scenario(name, params, SEED + idx * 211) |
| df.to_csv(output_dir / SCENARIO_FILES[name], index=False) |
| print(f"Saved {name} -> {SCENARIO_FILES[name]}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|