Beispiel #1
0
def dmcx(age, egfr, tchdl, acr, smoker, diab_dur, female, sbp, dbp, hba1c,
         htn_med, bmi, insulin, aGlucose):
    """
    Calculate the risk for cardiovascular disease
    using the coefficients from the DMCX Cohort

    Parameters
    ----------
    age : numeric
            Age of subject
    """
    # do some preprocessing
    age = clean_age(age)
    egfr = clean_egfr(egfr)
    sbp = clean_bp(sbp)
    dbp = clean_bp(dbp)
    bmi = clean_bmi(bmi)
    hba1c = clean_hba1c(hba1c)
    tchdl = clean_tchdl(tchdl)

    xFeat = np.array([
        age, egfr >= 60 and egfr < 90, egfr >= 30 and egfr < 60, egfr < 30,
        tchdl,
        np.log(clean_acr(acr) + 1), smoker,
        clean_diab_dur(diab_dur), sbp, hba1c, htn_med, dbp, bmi, insulin,
        dbp**2, bmi**2, sbp**2, hba1c**2, age * tchdl, age * hba1c,
        age * smoker, aGlucose
    ])
    coefInfo = MALE_DCMX
    if female:
        coefInfo = FEMALE_DCMX
    return cox_surv(xFeat, coefInfo["coef"], coefInfo["sm"], coefInfo["const"])
Beispiel #2
0
def frs_simple(female, age, bmi, sbp, htn, smk, diab):
    """
    10-year risk calculated using the Simple Non-Laboratory 
    Framingham Risk Score (FRS) Calculation.
    
    Parameters
    ----------
    female : boolean
    age : numeric
            Age of subject
    bmi : numeric
            BMI of subject
    sbp : numeric
            Systolic blood pressure of subject
    ht_treat : bool or int
            Treatment for hypertension (True or False)
    smk : bool or int
            Subject is smoker (True or False)
    diab : bool or int
            Subject has diabetes (True or False)
    """
    xFeat = np.array([np.log(clean_age(age)),
                      np.log(clean_bmi(bmi)),
                      np.log(clean_bp(sbp))*(1-htn),
                      np.log(clean_bp(sbp))*htn,
                      smk,
                      diab])
    genderInfo = NONLAB_MEN
    if female: 
        genderInfo = NONLAB_WOMEN
    return cox_surv(xFeat, genderInfo["coef"],
                    genderInfo["s0"], genderInfo["const"])
Beispiel #3
0
def ndr(diab_age,
        diab_dur,
        tchdl,
        hba1c,
        sbp,
        bmi,
        male,
        smoker,
        microalbum,
        macroalbum,
        afib,
        cvd,
        risk=5):
    if risk not in [4, 5]:
        raise NotImplementedError("Does not support risk that is not 4 or 5")
    baseSurv = S0_4
    if risk == 5:
        baseSurv = S0_5
    xFeat = np.array([
        diab_age - 53.858,
        clean_diab_dur(diab_dur) - 7.7360,
        np.log(clean_tchdl(tchdl)) - 1.3948,
        np.log(clean_hba1c(hba1c)) - 1.9736,
        np.log(clean_bp(sbp)) - 4.9441,
        np.log(clean_bmi(bmi)) - 3.3718, male - 0.6005, smoker - 0.1778,
        microalbum - 0.1604, macroalbum - 0.0638, afib - 0.0319, cvd - 0.1525
    ])
    s = cox_surv(xFeat, BETA, baseSurv)
    return s
Beispiel #4
0
def hkdr_hf(female, age, bmi, hba1c, acr, hb, chdHist):
    """
    Calculate the risk for heart failure
    using the coefficients from the HKDR Cohort

    Parameters
    ----------
    age : numeric
            Age of subject
    bmi : numeric
            BMI of the subject (in kg/m^2)
    hba1c: numeric
            HBA1C (%)
    acr : numeric
            Urinary albumin : creatinine ratio in mg/mmol
    hb : numeric
            Blood Hemoglobin (g/dl)
    chdHist : boolean or int
            Subject had CHD (true or False)
    """
    baseSurv = HKDR_HF["male_sm"]
    if female:
        baseSurv = HKDR_HF["female_sm"]
    xFeat = np.array([
        clean_age(age),
        clean_bmi(bmi),
        clean_hba1c(hba1c),
        np.log10(1 + clean_acr(acr)),
        clean_hb(hb), chdHist
    ])
    return cox_surv(xFeat, HKDR_HF["coef"], baseSurv, HKDR_HF["const"],
                    HKDR_HF["shrink"])
Beispiel #5
0
def dial(is_male,
         age,
         bmi,
         cur_smoke,
         sbp,
         non_hdl,
         hba1c,
         egfr,
         microalbumin,
         macroalbumin,
         diab_dur,
         cvd_hist,
         insulin,
         hz_treat=0,
         high_risk_county=False):
    # fix the age to be within 34-94
    age = np.clip(clean_age(age), 34, 94)
    diab_dur = int(round(clean_diab_dur(diab_dur)))
    bmi = clean_bmi(bmi)
    sbp = clean_bp(sbp)
    non_hdl = clean_nonhdl(non_hdl, meas="mmol")
    egfr = clean_egfr(egfr)
    hba1c = clean_hba1c(hba1c, meas="mmol")
    xFeat = np.array([
        is_male, age * is_male, bmi - 30, bmi**2 - 30**2, cur_smoke,
        age * cur_smoke, sbp - 140, sbp**2 - 140**2, non_hdl - 3.8,
        non_hdl**2 - 3.8**2, hba1c - 50, hba1c**2 - 50**2, egfr - 80,
        egfr**2 - 80**2, microalbumin, macroalbumin, diab_dur, cvd_hist,
        age * cvd_hist, insulin, age * insulin, hz_treat, high_risk_county
    ])
    # look-up the age-specific value
    s0 = AGE_S0[age]
    return cox_surv(xFeat, DIAL_COEF, s0)
Beispiel #6
0
def qdiabetes(age,
              male,
              bmi,
              diab_dur,
              ac,
              easian,
              hba1c,
              tchdl,
              sbp,
              heavy_smoke,
              moderate_smoke,
              light_smoke,
              prev_smoke,
              afib,
              cvd,
              renal,
              tYear=5,
              dmt1=False):
    genderInfo = FEMALE_CCF
    fractalFunc = _frac_poly_female
    if male:
        genderInfo = MALE_CCF
        fractalFunc = _frac_poly_male
    return _survival(clean_age(age), clean_bmi(bmi),
                     clean_diab_dur(diab_dur, 0), ac, easian,
                     clean_hba1c(hba1c, meas="mmol"), clean_tchdl(tchdl),
                     clean_bp(sbp), heavy_smoke, moderate_smoke, light_smoke,
                     prev_smoke, afib, cvd, renal, dmt1, genderInfo, tYear,
                     fractalFunc)
Beispiel #7
0
def ukpdsom2_chf(diabDur,
                 diabAge,
                 afib,
                 bmi,
                 egfr,
                 ldl,
                 mmalb,
                 pvd,
                 ampHist,
                 ulcHist,
                 tYear=1):
    """
    Calculate the number of years to forecast the risk.
    """
    egfr = clean_egfr(egfr)
    xFeat = np.array([
        diabAge, afib,
        clean_bmi(bmi), egfr / 10 if egfr < 60 else 0,
        clean_ldl(ldl) * 10, mmalb >= 50, pvd, ampHist, ulcHist
    ])
    return weibull_surv(xFeat, CHF_PARAMS["beta"], CHF_PARAMS["lambda"],
                        diabDur, diabDur + tYear, CHF_PARAMS["rho"])