Exemple #1
0
def fremantle(age, male, cvd, hba1c, acr, hdl_mmol, seurope, aboriginal):
    """
    Calculate the risk for cardiovascular disease
    using the coefficients from the Fremantle Cohort

    Parameters
    ----------
    age : numeric
            Age of subject
    isMale : boolean or int
            Subject is male (True or False)
    cvd: boolean or int
            Previous history of CVD (True or False)
    hba1c : numeric
            Hba1c (%) of subject
    acr : numeric
            Urinary albumin : creatinine ratio in mg/mmol
    hdl : numeric
            High density lipid cholestrol in mmol/L
    seurope : bool or int
            Subject is Southern European (True or False)
    aboriginal : bool or int
            Subject is Indigenous Australian (True or False)
    """
    xFeat = np.array([
        clean_age(age), male, cvd,
        np.log(clean_hba1c(hba1c)),
        np.log(clean_acr(acr)),
        np.log(clean_hdl(hdl_mmol, meas="mmol")), seurope, aboriginal
    ])
    return cox_surv(xFeat, FREMANTLE_COEF, FREMANTLE_SM, FREMANTLE_CONST)
Exemple #2
0
def recode(age,
           female,
           ethnicity,
           smoking,
           sbp,
           cvdHist,
           bpld,
           statin,
           anticoag,
           hba1c,
           tchol,
           hdl,
           creat,
           acr,
           target="CHF"):
    coefInfo = CHD_INFO
    if target == "MI":
        coefInfo = MI_INFO
    if target == "STROKE":
        coefInfo = STROKE_INFO
    """
    Calculate the survival value
    """
    xFeat = np.array([
        clean_age(age), female, ethnicity, smoking,
        clean_bp(sbp), cvdHist, bpld, statin, anticoag,
        clean_hba1c(hba1c),
        clean_tot_chol(tchol),
        clean_hdl(hdl), creat,
        clean_acr(acr)
    ])
    return cox_surv(xFeat, coefInfo["coef"], coefInfo["s0"], coefInfo["const"])
Exemple #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
Exemple #4
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"])
Exemple #5
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"])
Exemple #6
0
def hkdr_stroke(age, hba1c, acr, chd):
    xFeat = np.array(
        [clean_age(age),
         clean_hba1c(hba1c),
         np.log10(clean_acr(acr)), chd])
    return cox_surv(xFeat, HKDR_STROKE["coef"], HKDR_STROKE["sm"],
                    HKDR_STROKE["const"])
Exemple #7
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)
Exemple #8
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)
Exemple #9
0
def ukpdsom2_mi_female(ac,
                       diab_dur,
                       diab_age,
                       egfr,
                       hba1c,
                       ldl,
                       mmalb,
                       pvd,
                       sbp,
                       cur_smoke,
                       wbc,
                       chf_hist,
                       chd_hist,
                       tYear=1):
    """
    Calculate the number of years to forecast the risk.
    """
    ldl = clean_ldl(ldl)
    egfr = clean_egfr(egfr)
    xFeat = np.array([
        ac, diab_age, egfr / 10 if egfr < 60 else 0,
        clean_hba1c(hba1c), ldl * 10 if ldl > 35 else 0, mmalb >= 50, pvd,
        clean_bp(sbp) / 10, cur_smoke, wbc, chf_hist, chd_hist
    ])
    return weibull_surv(xFeat, MI_FEMALE_PARAMS["beta"],
                        MI_FEMALE_PARAMS["lambda"], diab_dur, diab_dur + tYear,
                        MI_MALE_PARAMS["rho"])
Exemple #10
0
def ukpdsom2_mi_male(ac,
                     diab_dur,
                     diab_age,
                     easian,
                     hba1c,
                     hdl,
                     ldl,
                     mmalb,
                     pvd,
                     sbp,
                     cur_smoke,
                     wbc,
                     amp_hist,
                     chf_hist,
                     chd_hist,
                     stroke_hist,
                     tYear=1):
    """
    Calculate the number of years to forecast the risk.
    """

    xFeat = np.array([
        ac, diab_age, easian,
        clean_hba1c(hba1c),
        clean_hdl(hdl) * 10,
        clean_ldl(ldl) * 10, mmalb >= 50, pvd,
        clean_bp(sbp) / 10, cur_smoke, wbc, amp_hist, chf_hist, chd_hist,
        stroke_hist
    ])
    return weibull_surv(xFeat, MI_MALE_PARAMS["beta"],
                        MI_MALE_PARAMS["lambda"], diab_dur, diab_dur + tYear,
                        MI_MALE_PARAMS["rho"])
Exemple #11
0
def advance(diab_age, female, diab_dur, pp, retin, afib, hba1c, acr, non_hdl,
            htn_treat):
    # add ability to ensure specific values are not negative
    xFeat = np.array([
        diab_age, female,
        clean_diab_dur(diab_dur),
        clean_pp(pp), retin, afib,
        clean_hba1c(hba1c),
        np.log(clean_acr(acr)),
        clean_nonhdl(non_hdl), htn_treat
    ])
    s = cox_surv(xFeat, BETA, S_0, CONST)
    return s
Exemple #12
0
def darts(diab_age, diab_dur, chol_tot, prev_smoker, cur_smoker, male, hba1c,
          follow5, sbp, htn, height, t):
    hba1c = clean_hba1c(hba1c)
    sbp = clean_bp(sbp)
    xFeat = np.array([
        np.log(clean_diab_dur(diab_dur)), diab_age,
        clean_tot_chol(chol_tot), prev_smoker, cur_smoker, male,
        np.log(hba1c),
        np.log(hba1c) * follow5, sbp, htn, sbp * htn,
        clean_height(height)
    ])
    s = weibull_atf_surv(xFeat, BETA, INTERCEPT, SIGMA, t)
    return s
Exemple #13
0
def ukpds(ageDiab, age, female, ac, smoking, hba1c, sbp, tchdl, tYear=10):
    """
    Calculate the number of years to forecast the risk.
    """
    xFeat = np.array([clean_age(age)-55,
                      female,
                      ac,
                      bool(smoking),
                      clean_hba1c(hba1c)-6.72,
                      (clean_bp(sbp) - 135.7)/10,
                      np.log(clean_tchdl(tchdl))-1.59])
    q = Q_0 * np.prod(np.power(BETA, xFeat))
    uscore = 1 - np.exp(-q * D**(age-ageDiab)* (1-D**tYear)/ (1 - D))
    return max(uscore, 0.0)
Exemple #14
0
def ukpdsom2_stroke(diab_dur,
                    diab_age,
                    female,
                    afib,
                    egfr,
                    hba1c,
                    ldl,
                    mmalb,
                    sbp,
                    cur_smoke,
                    wbc,
                    amp_hist,
                    chd_hist,
                    tYear=1):
    """
    Calculate the number of years to forecast the risk.
    """
    xFeat = np.array([
        diab_age, female, afib, egfr / 10 if egfr < 60 else 0,
        clean_hba1c(hba1c), ldl * 10, mmalb >= 50,
        clean_bp(sbp) / 10, cur_smoke, wbc, amp_hist, chd_hist
    ])
    return weibull_surv(xFeat, STROKE_PARAMS["beta"], STROKE_PARAMS["lambda"],
                        diab_dur, diab_dur + tYear, STROKE_PARAMS["rho"])