def get_risks(): risks = gbd.get_rei_metadata(rei_set_id=RISK_SET_ID) risks = pd.DataFrame({ "rei_name": clean_entity_list(risks.rei_name), "rei_id": risks.rei_id }) return risks.sort_values("rei_id")
def get_etiologies(): etiologies = gbd.get_rei_metadata(rei_set_id=ETIOLOGY_SET_ID) etiologies = etiologies[etiologies["most_detailed"] == 1] etiologies = pd.DataFrame({ "rei_name": clean_entity_list(etiologies.rei_name), "rei_id": etiologies.rei_id }) return etiologies.sort_values("rei_id")
def get_etiologies(): etiologies = gbd.get_rei_metadata(rei_set_id=ETIOLOGY_SET_ID) etiologies = etiologies[etiologies['most_detailed'] == 1] etiologies = pd.DataFrame({ 'rei_name': clean_entity_list(etiologies.rei_name), 'rei_id': etiologies.rei_id }) return etiologies.sort_values('rei_id')
def get_all_risk_metadata(): risks = gbd.get_rei_metadata(RISK_SET_ID).sort_values("rei_id") risks = risks[[ "rei_id", "level", "rei_name", "parent_id", "most_detailed" ]].set_index("rei_id") risks["rei_name"] = clean_entity_list(risks["rei_name"]) risks = risks.join(gbd.get_paf_of_one().set_index("rei_id")) risks = risks.join(gbd.get_cause_risk_mapping().set_index("rei_id")) risks = risks.join(gbd.get_category_mapping().set_index("rei_id")) risks = risks.join(gbd.get_mediation_mapping().set_index("rei_id")) risks = risks.join(gbd.get_risk_metadata().set_index("rei_id")) risks.rei_calculation_type = risks.rei_calculation_type.map({ "0": "aggregation", "1": "categorical", "2": "continuous", "3": "custom", "4": "direct", }) return risks
def get_all_risk_metadata(): risks = gbd.get_rei_metadata(RISK_SET_ID).sort_values('rei_id') risks = risks[[ 'rei_id', 'level', 'rei_name', 'parent_id', 'most_detailed' ]].set_index('rei_id') risks['rei_name'] = clean_entity_list(risks['rei_name']) risks = risks.join(gbd.get_paf_of_one().set_index('rei_id')) risks = risks.join(gbd.get_cause_risk_mapping().set_index('rei_id')) risks = risks.join(gbd.get_category_mapping().set_index('rei_id')) risks = risks.join(gbd.get_mediation_mapping().set_index('rei_id')) risks = risks.join(gbd.get_risk_metadata().set_index('rei_id')) risks.rei_calculation_type = risks.rei_calculation_type.map({ '0': 'aggregation', '1': 'categorical', '2': 'continuous', '3': 'custom', '4': 'direct' }) return risks
def get_etiology_data(with_survey): etiologies = gbd.get_rei_metadata(rei_set_id=ETIOLOGY_SET_ID) etiologies = etiologies[etiologies['most_detailed'] == 1] if with_survey: data_survey = gbd.get_survey_summary('etiology', SURVEY_LOCATION_ID) assert len(etiologies) == len(data_survey) etiologies = pd.merge(data_survey, etiologies, left_on=['etiology_id'], right_on=['rei_id']).sort_values(['rei_id']) else: data_survey = make_empty_survey([ 'paf_yll_exists', 'paf_yld_exists', 'paf_yll_in_range', 'paf_yld_in_range' ], index=etiologies.index) etiologies = etiologies.join(data_survey) return list( zip(clean_entity_list(etiologies.rei_name), etiologies.rei_id, etiologies.paf_yll_exists, etiologies.paf_yld_exists, etiologies.paf_yll_in_range, etiologies.paf_yld_in_range))
def get_cause_data(): sequelae = gbd.get_sequela_id_mapping().sort_values("sequela_id") etiologies = gbd.get_rei_metadata(rei_set_id=ETIOLOGY_SET_ID) etiologies = etiologies[etiologies["most_detailed"] == 1].sort_values( "rei_id") cause_etiology_map = gbd.get_cause_etiology_mapping() cause_me_map = gbd.get_cause_me_id_mapping() cause_me_map["cause_name"] = clean_entity_list( cause_me_map["modelable_entity_name"]) cause_me_map = cause_me_map[["modelable_entity_id", "cause_name"]].set_index("cause_name") causes = gbd.get_cause_metadata(cause_set_id=CAUSE_SET_ID) causes = pd.DataFrame({ "cause_name": clean_entity_list(causes.cause_name), "cause_id": causes.cause_id, "parent_id": causes.parent_id, "most_detailed": causes.most_detailed, "level": causes.level, "male": causes.male.replace({ np.NaN: False, 1: True }), "female": causes.female.replace({ np.NaN: False, 1: True }), "yll_only": causes.yll_only.replace({ np.NaN: False, 1: True }), "yld_only": causes.yld_only.replace({ np.NaN: False, 1: True }), "yll_age_start": causes.yll_age_start.replace({np.NaN: 0}), "yll_age_end": causes.yll_age_end.replace({np.NaN: 95}), "yld_age_start": causes.yld_age_start.replace({np.NaN: 0}), "yld_age_end": causes.yld_age_end.replace({np.NaN: 95}), }) causes = (causes.set_index("cause_name").join(cause_me_map).sort_values( "cause_id").reset_index()) cause_data = [] for _, cause in causes.iterrows(): name = cause["cause_name"] cid = cause["cause_id"] parent = causes.set_index("cause_id").at[cause["parent_id"], "cause_name"] dismod_id = cause["modelable_entity_id"] most_detailed = cause["most_detailed"] level = cause["level"] restrictions = make_cause_restrictions(cause) eti_ids = cause_etiology_map[cause_etiology_map.cause_id == cid].rei_id.tolist() associated_etiologies = clean_entity_list( etiologies[etiologies.rei_id.isin(eti_ids)].rei_name) associated_sequelae = clean_entity_list( sequelae[sequelae.cause_id == cid].sequela_name) sub_causes = causes[causes.parent_id == cid].cause_name.tolist() cause_data.append(( name, cid, dismod_id, most_detailed, level, parent, restrictions, associated_sequelae, associated_etiologies, sub_causes, )) return cause_data
def get_etiology_data() -> List: etiologies = gbd.get_rei_metadata(rei_set_id=ETIOLOGY_SET_ID) etiologies = etiologies[etiologies["most_detailed"] == 1] return list(zip(clean_entity_list(etiologies.rei_name), etiologies.rei_id))
def get_cause_data(with_survey): sequelae = gbd.get_sequela_id_mapping().sort_values('sequela_id') etiologies = gbd.get_rei_metadata(rei_set_id=ETIOLOGY_SET_ID) etiologies = etiologies[etiologies['most_detailed'] == 1].sort_values( 'rei_id') cause_etiology_map = gbd.get_cause_etiology_mapping() cause_me_map = gbd.get_cause_me_id_mapping() cause_me_map['cause_name'] = clean_entity_list( cause_me_map['modelable_entity_name']) cause_me_map = cause_me_map[['modelable_entity_id', 'cause_name']].set_index('cause_name') causes = gbd.get_cause_metadata(cause_set_id=CAUSE_SET_ID) causes = pd.DataFrame({ 'cause_name': clean_entity_list(causes.cause_name), 'cause_id': causes.cause_id, 'parent_id': causes.parent_id, 'most_detailed': causes.most_detailed, 'level': causes.level, 'male': causes.male.replace({ np.NaN: False, 1: True }), 'female': causes.female.replace({ np.NaN: False, 1: True }), 'yll_only': causes.yll_only.replace({ np.NaN: False, 1: True }), 'yld_only': causes.yld_only.replace({ np.NaN: False, 1: True }), 'yll_age_start': causes.yll_age_start.replace({np.NaN: 0}), 'yll_age_end': causes.yll_age_end, 'yld_age_start': causes.yld_age_start.replace({np.NaN: 0}), 'yld_age_end': causes.yld_age_end }) if with_survey: data_survey = gbd.get_survey_summary('cause', SURVEY_LOCATION_ID) assert len(causes) == len(data_survey) causes = causes.merge(data_survey, on='cause_id') else: data_survey = make_empty_survey([ 'prevalence_exists', 'incidence_exists', 'remission_exists', 'deaths_exists', 'birth_prevalence_exists', 'prevalence_in_range', 'incidence_in_range', 'remission_in_range', 'deaths_in_range', 'birth_prevalence_in_range', 'prevalence_consistent', 'incidence_consistent', 'deaths_consistent', 'birth_prevalence_consistent', 'prevalence_aggregates', 'incidence_aggregates', 'deaths_aggregates', 'birth_prevalence_aggregates', 'violated_restrictions' ], index=causes.index) causes = causes.join(data_survey) causes = causes.set_index('cause_name').join(cause_me_map).sort_values( 'cause_id').reset_index() cause_data = [] for _, cause in causes.iterrows(): name = cause['cause_name'] cid = cause['cause_id'] parent = causes.set_index('cause_id').at[cause['parent_id'], 'cause_name'] dismod_id = cause['modelable_entity_id'] most_detailed = cause['most_detailed'] level = cause['level'] restrictions = make_cause_restrictions(cause) prev_exists = cause['prevalence_exists'] inc_exists = cause['incidence_exists'] remission_exists = cause['remission_exists'] deaths_exists = cause['deaths_exists'] birth_prevalence_exists = cause['birth_prevalence_exists'] prev_in_range = cause['prevalence_in_range'] inc_in_range = cause['incidence_in_range'] remission_in_range = cause['remission_in_range'] deaths_in_range = cause['deaths_in_range'] birth_prev_in_range = cause['birth_prevalence_in_range'] prev_consistent = cause['prevalence_consistent'] inc_consistent = cause['incidence_consistent'] deaths_consistent = cause['deaths_consistent'] birth_prev_consistent = cause['birth_prevalence_consistent'] prev_aggregates = cause['prevalence_aggregates'] inc_aggregates = cause['incidence_aggregates'] deaths_aggregates = cause['deaths_aggregates'] birth_prev_aggregates = cause['birth_prevalence_aggregates'] eti_ids = cause_etiology_map[cause_etiology_map.cause_id == cid].rei_id.tolist() associated_etiologies = clean_entity_list( etiologies[etiologies.rei_id.isin(eti_ids)].rei_name) associated_sequelae = clean_entity_list( sequelae[sequelae.cause_id == cid].sequela_name) sub_causes = causes[causes.parent_id == cid].cause_name.tolist() cause_data.append( (name, cid, dismod_id, most_detailed, level, parent, restrictions, prev_exists, inc_exists, remission_exists, deaths_exists, birth_prevalence_exists, prev_in_range, inc_in_range, remission_in_range, deaths_in_range, birth_prev_in_range, prev_consistent, inc_consistent, deaths_consistent, birth_prev_consistent, prev_aggregates, inc_aggregates, deaths_aggregates, birth_prev_aggregates, associated_sequelae, associated_etiologies, sub_causes)) return cause_data