コード例 #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"])
コード例 #2
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
コード例 #3
0
def hkdr_chd(age, female, cur_smoker, diab_dur, egfr, acr, nonhdl_mmol):
    """
    Calculate the risk for coronary heart disease
    using the coefficients from the HKDR CHD Cohort

    Parameters
    ----------
    age : numeric
            Age of subject
    isFemale : boolean or int
            Subject is female (True or False)
    curSmoke: boolean or int
            Previous history of CVD (True or False)
    diabDur : numeric
            Nubmer of years of diabetes
    egfr : numeric
            Estimated Glomerular Filteration Rate
    acr : numeric
            Urinary albumin : creatinine ratio in mg/mmol
    nonHDL : numeric
            Non-HDL cholesterol (mmol/L)
    """
    xFeat = np.array([
        clean_age(age), female, cur_smoker,
        clean_diab_dur(diab_dur),
        np.log10(clean_egfr(egfr)),
        np.log10(1 + clean_acr(acr)),
        clean_nonhdl(nonhdl_mmol, meas="mmol")
    ])
    return cox_surv(xFeat, HKDR_CHD["coef"], HKDR_CHD["sm"], HKDR_CHD["const"],
                    HKDR_CHD["shrink"])
コード例 #4
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)
コード例 #5
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)
コード例 #6
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
コード例 #7
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