#!/usr/bin/env python3 import math CONSTANT = -19.907 ALBUMIN = -0.0336 CREATININE = 0.0095 GLUCOSE = 0.0195 CRP = 0.0954 LYPHOCYTE_PERCENT = -0.0120 MEAN_CELL_VOLUME = 0.0268 RED_BLOOD_CELL_DIST_WIDTH = 0.3356 ALKALINE_PHOSPHATASE = 0.00188 WHITE_BLOOD_CELL_COUNT = 0.0554 CHRONO_AGE = 0.0804 def xb_var(albumin, creatinine, glucose, crp, lyphocyte_percent, mean_cell_volume, red_blood_cell_dist_width, alkaline_phosphatase, white_blood_cell_count, chrono_age): xb_var = CONSTANT xb_var += ALBUMIN * albumin xb_var += CREATININE * creatinine xb_var += GLUCOSE * glucose xb_var += CRP * math.log(crp) xb_var += LYPHOCYTE_PERCENT * lyphocyte_percent xb_var += MEAN_CELL_VOLUME * mean_cell_volume xb_var += RED_BLOOD_CELL_DIST_WIDTH * red_blood_cell_dist_width xb_var += ALKALINE_PHOSPHATASE * alkaline_phosphatase xb_var += WHITE_BLOOD_CELL_COUNT * white_blood_cell_count xb_var += CHRONO_AGE * chrono_age return xb_var def pheno_age(albumin, creatinine, glucose, crp, lyphocyte_percent, mean_cell_volume, red_blood_cell_dist_width, alkaline_phosphatase, white_blood_cell_count, chrono_age): xb = xb_var(albumin, creatinine, glucose, crp, lyphocyte_percent, mean_cell_volume, red_blood_cell_dist_width, alkaline_phosphatase, white_blood_cell_count, chrono_age) pa = 141.5 + math.log(-0.00553 + math.log(1 - xb)) / .09165 return pa def demo(): albumin = 4.1 creatinine = 1.1 glucose = 81 crp = 0.8 lyphocyte_percent = 42 mean_cell_volume = 95 red_blood_cell_dist_width = 13.5 alkaline_phosphatase = 56 white_blood_cell_count = 3.8 chrono_age = 54 print(xb_var(albumin, creatinine, glucose, crp, lyphocyte_percent, mean_cell_volume, red_blood_cell_dist_width, alkaline_phosphatase, white_blood_cell_count, chrono_age)) print('age = ', pheno_age(albumin, creatinine, glucose, crp, lyphocyte_percent, mean_cell_volume, red_blood_cell_dist_width, alkaline_phosphatase, white_blood_cell_count, chrono_age)) demo()