Module:BiologicalAgeBiomarkers: Difference between revisions

    From Longevity Wiki
    No edit summary
    No edit summary
    Line 3: Line 3:
    -- Define biomarkers with their long form and system
    -- Define biomarkers with their long form and system
    local biomarkers = {
    local biomarkers = {
      -- Cardiovascular System
         SBP = {name = "Systolic Blood Pressure (SBP)", system = "Cardiovascular System"},
         SBP = {name = "Systolic Blood Pressure (SBP)", system = "Cardiovascular System"},
         DBP = {name = "Diastolic Blood Pressure (DBP)", system = "Cardiovascular System"},
         DBP = {name = "Diastolic Blood Pressure (DBP)", system = "Cardiovascular System"},
        PP = {name = "Pulse Pressure", system = "Cardiovascular System"},
        MAP = {name = "Mean Arterial Pressure", system = "Cardiovascular System"},
        Pulse = {name = "Pulse", system = "Cardiovascular System"},
        PWV = {name = "Pulse Wave Velocity", system = "Cardiovascular System"},
        HR = {name = "Heart Rate", system = "Cardiovascular System"},
        IMT = {name = "Intima-Media Thickness", system = "Cardiovascular System"},
        MinIMT = {name = "Minimum Intima-Media Thickness", system = "Cardiovascular System"},
        EDV = {name = "End Diastolic Velocity", system = "Cardiovascular System"},
        MVEAP = {name = "Mitral Valve E/A Peak", system = "Cardiovascular System"},
        MVEL_MVES_MVEA = {name = "MVEL, MVES, MVEA", system = "Cardiovascular System"},
        AI = {name = "Atherosclerosis Index", system = "Cardiovascular System"},
        NTproBNP = {name = "NT-proBNP", system = "Cardiovascular System"},
        CTnI = {name = "Cardiac Troponin I", system = "Cardiovascular System"},
        CPK = {name = "Creatine Phosphokinase", system = "Cardiovascular System"},
        Homocysteine = {name = "Homocysteine", system = "Cardiovascular System"},
        -- Respiratory System
        FVC = {name = "Forced Vital Capacity (FVC)", system = "Respiratory System"},
        FEV1 = {name = "Forced Expiratory Volume in 1 Second (FEV1)", system = "Respiratory System"},
        VC = {name = "Vital Capacity", system = "Respiratory System"},
        MMFR = {name = "Maximal Midexpiratory Flow Rate 75/25", system = "Respiratory System"},
        VO2Max = {name = "VO2 Max", system = "Respiratory System"},
        CR = {name = "Chest Radiography", system = "Respiratory System"},
        -- Nervous System
        MMSE = {name = "Mini-Mental State Examination (MMSE)", system = "Nervous System"},
        DST = {name = "Digital Symbol Test", system = "Nervous System"},
        NM = {name = "Numeric Memory", system = "Nervous System"},
        AM = {name = "Associated Memory", system = "Nervous System"},
        TM = {name = "Topological Memory", system = "Nervous System"},
        STM = {name = "Short-Time Memory", system = "Nervous System"},
        Concentration = {name = "Concentration", system = "Nervous System"},
        IMD = {name = "Intellectuality - Mental Defect", system = "Nervous System"},
        TMT = {name = "Trail Making Test", system = "Nervous System"},
        -- Endocrine Metabolic System
        Glucose = {name = "Glucose", system = "Endocrine Metabolic System"},
        HBA1C = {name = "HBA1C", system = "Endocrine Metabolic System"},
        CPeptide = {name = "C-peptide", system = "Endocrine Metabolic System"},
        Insulin = {name = "Insulin", system = "Endocrine Metabolic System"},
        TG = {name = "Triglyceride", system = "Endocrine Metabolic System"},
        TC = {name = "Total Cholesterol (TC)", system = "Endocrine Metabolic System"},
         HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
         HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
         LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"}
         LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"},
        ApoA1B = {name = "Apolipoprotein A1 and B", system = "Endocrine Metabolic System"},
        TSH = {name = "Thyroid-Stimulating Hormone (TSH)", system = "Endocrine Metabolic System"},
        Testosterone = {name = "Testosterone", system = "Endocrine Metabolic System"},
        VitaminD = {name = "Vitamin D", system = "Endocrine Metabolic System"},
        Calcium = {name = "Calcium", system = "Endocrine Metabolic System"},
        Potassium = {name = "Potassium", system = "Endocrine Metabolic System"},
        Sodium = {name = "Sodium", system = "Endocrine Metabolic System"},
        InorganicPhosphorus = {name = "Inorganic Phosphorus", system = "Endocrine Metabolic System"},
        Urea = {name = "Urea", system = "Endocrine Metabolic System"},
        Creatinine = {name = "Creatinine", system = "Endocrine Metabolic System"},
        eGFR = {name = "Estimated Glomerular Filtration Rate (eGFR)", system = "Endocrine Metabolic System"},
        UricAcid = {name = "Uric Acid", system = "Endocrine Metabolic System"},
        CystatinC = {name = "Cystatin C", system = "Endocrine Metabolic System"},
        CreatinineClearance = {name = "Creatinine Clearance", system = "Endocrine Metabolic System"},
        UrineSG = {name = "Urine Specific Gravity", system = "Endocrine Metabolic System"},
        UrinepH = {name = "Urine pH", system = "Endocrine Metabolic System"},
     
        -- Digestive System
        ALT = {name = "Alanine Aminotransferase (ALT)", system = "Digestive System"},
        AST = {name = "Aspartate Aminotransferase (AST)", system = "Digestive System"},
        ALP = {name = "Alkaline Phosphatase (ALP)", system = "Digestive System"},
        TotalProtein = {name = "Total Protein", system = "Digestive System"},
        Albumin = {name = "Albumin", system = "Digestive System"},
        AGRatio = {name = "Albumin/Globulin Ratio (A/G)", system = "Digestive System"},
        TotalBilirubin = {name = "Total Bilirubin", system = "Digestive System"},
        DirectBilirubin = {name = "Direct Bilirubin", system = "Digestive System"},
        Amylase = {name = "Amylase", system = "Digestive System"},
        LDH = {name = "Lactate Dehydrogenase", system = "Digestive System"},
        Alpha2Globulin = {name = "Alpha 2 Globulin", system = "Digestive System"},
        GGT = {name = "Gamma Glutamyl Transpeptidase", system = "Digestive System"},
     
        -- Hematologic System
        RBC = {name = "Red Blood Cell", system = "Hematologic System"},
        RDW = {name = "Red Blood Cell Volume Distribution Width", system = "Hematologic System"},
        Hematocrit = {name = "Hematocrit", system = "Hematologic System"},
        MCV = {name = "Mean Corpuscular Volume", system = "Hematologic System"},
        MCH = {name = "Mean Corpuscular Hemoglobin", system = "Hematologic System"},
        MCHC = {name = "Mean Corpuscular Hemoglobin Concentration", system = "Hematologic System"},
        Hemoglobin = {name = "Hemoglobin", system = "Hematologic System"},
        WBC = {name = "White Blood Cell", system = "Hematologic System"},
        Granulocytes = {name = "Granulocytes", system = "Hematologic System"},
        Neutrophils = {name = "Neutrophils", system = "Hematologic System"},
        BasophilsEosinophils = {name = "Basophils, Eosinophils", system = "Hematologic System"},
        Lymphocytes = {name = "Lymphocytes", system = "Hematologic System"},
        Monocytes = {name = "Monocytes", system = "Hematologic System"},
        Platelet = {name = "Platelet", system = "Hematologic System"},
        MPV = {name = "Mean Platelet Volume", system = "Hematologic System"},
        PDW = {name = "Platelet Distribution Width", system = "Hematologic System"},
        ESR = {name = "Erythrocyte Sedimentation Rate", system = "Hematologic System"},
        DdimerFibrinogen = {name = "D-dimer, Fibrinogen", system = "Hematologic System"},
        Ferritin = {name = "Ferritin", system = "Hematologic System"},
        Transferrin = {name = "Transferrin", system = "Hematologic System"},
     
        -- Sensory System
        VisualAcc = {name = "Visual Accommodation", system = "Sensory System"},
        VisualReactTime = {name = "Visual Reaction Time", system = "Sensory System"},
        VisualAcuity = {name = "Visual Acuity", system = "Sensory System"},
        Hearing = {name = "Hearing", system = "Sensory System"},
        Vibrotactile = {name = "Vibrotactile", system = "Sensory System"},
        RetinalPhotos = {name = "Retinal Photos", system = "Sensory System"},
     
        -- Inflammatory Index
        CRP = {name = "C-Reactive Protein (CRP)", system = "Inflammatory Index"},
        CMVOptDensity = {name = "Cytomegalovirus Optical Density", system = "Inflammatory Index"},
        IL6 = {name = "Interleukin-6", system = "Inflammatory Index"},
        Pselectin = {name = "P-selectin", system = "Inflammatory Index"},
     
        -- Motion Index
        GripStrength = {name = "Grip Strength", system = "Motion Index"},
        VerticalJump = {name = "Vertical Jump", system = "Motion Index"},
        TUGTest = {name = "Timed Up and Go Test", system = "Motion Index"},
        ChairRiseTime = {name = "Chair Rise Time", system = "Motion Index"},
        PhysicalActivityWeek = {name = "1-Week Physical Activity", system = "Motion Index"},
     
        -- Body Morphology Index
        WaistCirc = {name = "Waist Circumference (WC)", system = "Body Morphology Index"},
        WaistHipRatio = {name = "Waist-to-Hip Ratio", system = "Body Morphology Index"},
        WaistHeightRatio = {name = "Waist-to-Height Ratio", system = "Body Morphology Index"},
        BMI = {name = "Body Mass Index (BMI)", system = "Body Morphology Index"},
        Weight = {name = "Weight", system = "Body Morphology Index"},
        Height = {name = "Height", system = "Body Morphology Index"},
        BodyFat = {name = "Body Fat", system = "Body Morphology Index"},
        LeanBodyMass = {name = "Lean Body Mass", system = "Body Morphology Index"},
        SoftLeanMass = {name = "Soft Lean Mass", system = "Body Morphology Index"},
     
        -- Genetic Index
        TelomereLength = {name = "Terminal Telomere Restriction Fragment", system = "Genetic Index"}
    }
    }



    Revision as of 01:57, 19 February 2024

    Output the biological age biomarkers table.

    Data is stored in Module:BiologicalAgeBiomarkers/Data


    local p = {}
    
    -- Define biomarkers with their long form and system
    local biomarkers = {
       -- Cardiovascular System
        SBP = {name = "Systolic Blood Pressure (SBP)", system = "Cardiovascular System"},
        DBP = {name = "Diastolic Blood Pressure (DBP)", system = "Cardiovascular System"},
        PP = {name = "Pulse Pressure", system = "Cardiovascular System"},
        MAP = {name = "Mean Arterial Pressure", system = "Cardiovascular System"},
        Pulse = {name = "Pulse", system = "Cardiovascular System"},
        PWV = {name = "Pulse Wave Velocity", system = "Cardiovascular System"},
        HR = {name = "Heart Rate", system = "Cardiovascular System"},
        IMT = {name = "Intima-Media Thickness", system = "Cardiovascular System"},
        MinIMT = {name = "Minimum Intima-Media Thickness", system = "Cardiovascular System"},
        EDV = {name = "End Diastolic Velocity", system = "Cardiovascular System"},
        MVEAP = {name = "Mitral Valve E/A Peak", system = "Cardiovascular System"},
        MVEL_MVES_MVEA = {name = "MVEL, MVES, MVEA", system = "Cardiovascular System"},
        AI = {name = "Atherosclerosis Index", system = "Cardiovascular System"},
        NTproBNP = {name = "NT-proBNP", system = "Cardiovascular System"},
        CTnI = {name = "Cardiac Troponin I", system = "Cardiovascular System"},
        CPK = {name = "Creatine Phosphokinase", system = "Cardiovascular System"},
        Homocysteine = {name = "Homocysteine", system = "Cardiovascular System"},
    
        -- Respiratory System
        FVC = {name = "Forced Vital Capacity (FVC)", system = "Respiratory System"},
        FEV1 = {name = "Forced Expiratory Volume in 1 Second (FEV1)", system = "Respiratory System"},
        VC = {name = "Vital Capacity", system = "Respiratory System"},
        MMFR = {name = "Maximal Midexpiratory Flow Rate 75/25", system = "Respiratory System"},
        VO2Max = {name = "VO2 Max", system = "Respiratory System"},
        CR = {name = "Chest Radiography", system = "Respiratory System"},
    
        -- Nervous System
        MMSE = {name = "Mini-Mental State Examination (MMSE)", system = "Nervous System"},
        DST = {name = "Digital Symbol Test", system = "Nervous System"},
        NM = {name = "Numeric Memory", system = "Nervous System"},
        AM = {name = "Associated Memory", system = "Nervous System"},
        TM = {name = "Topological Memory", system = "Nervous System"},
        STM = {name = "Short-Time Memory", system = "Nervous System"},
        Concentration = {name = "Concentration", system = "Nervous System"},
        IMD = {name = "Intellectuality - Mental Defect", system = "Nervous System"},
        TMT = {name = "Trail Making Test", system = "Nervous System"},
    
        -- Endocrine Metabolic System
        Glucose = {name = "Glucose", system = "Endocrine Metabolic System"},
        HBA1C = {name = "HBA1C", system = "Endocrine Metabolic System"},
        CPeptide = {name = "C-peptide", system = "Endocrine Metabolic System"},
        Insulin = {name = "Insulin", system = "Endocrine Metabolic System"},
        TG = {name = "Triglyceride", system = "Endocrine Metabolic System"},
        TC = {name = "Total Cholesterol (TC)", system = "Endocrine Metabolic System"},
        HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
        LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"},
        ApoA1B = {name = "Apolipoprotein A1 and B", system = "Endocrine Metabolic System"},
        TSH = {name = "Thyroid-Stimulating Hormone (TSH)", system = "Endocrine Metabolic System"},
        Testosterone = {name = "Testosterone", system = "Endocrine Metabolic System"},
        VitaminD = {name = "Vitamin D", system = "Endocrine Metabolic System"},
        Calcium = {name = "Calcium", system = "Endocrine Metabolic System"},
        Potassium = {name = "Potassium", system = "Endocrine Metabolic System"},
        Sodium = {name = "Sodium", system = "Endocrine Metabolic System"},
        InorganicPhosphorus = {name = "Inorganic Phosphorus", system = "Endocrine Metabolic System"},
        Urea = {name = "Urea", system = "Endocrine Metabolic System"},
        Creatinine = {name = "Creatinine", system = "Endocrine Metabolic System"},
        eGFR = {name = "Estimated Glomerular Filtration Rate (eGFR)", system = "Endocrine Metabolic System"},
        UricAcid = {name = "Uric Acid", system = "Endocrine Metabolic System"},
        CystatinC = {name = "Cystatin C", system = "Endocrine Metabolic System"},
        CreatinineClearance = {name = "Creatinine Clearance", system = "Endocrine Metabolic System"},
        UrineSG = {name = "Urine Specific Gravity", system = "Endocrine Metabolic System"},
        UrinepH = {name = "Urine pH", system = "Endocrine Metabolic System"},
    
        -- Digestive System
        ALT = {name = "Alanine Aminotransferase (ALT)", system = "Digestive System"},
        AST = {name = "Aspartate Aminotransferase (AST)", system = "Digestive System"},
        ALP = {name = "Alkaline Phosphatase (ALP)", system = "Digestive System"},
        TotalProtein = {name = "Total Protein", system = "Digestive System"},
        Albumin = {name = "Albumin", system = "Digestive System"},
        AGRatio = {name = "Albumin/Globulin Ratio (A/G)", system = "Digestive System"},
        TotalBilirubin = {name = "Total Bilirubin", system = "Digestive System"},
        DirectBilirubin = {name = "Direct Bilirubin", system = "Digestive System"},
        Amylase = {name = "Amylase", system = "Digestive System"},
        LDH = {name = "Lactate Dehydrogenase", system = "Digestive System"},
        Alpha2Globulin = {name = "Alpha 2 Globulin", system = "Digestive System"},
        GGT = {name = "Gamma Glutamyl Transpeptidase", system = "Digestive System"},
    
        -- Hematologic System
        RBC = {name = "Red Blood Cell", system = "Hematologic System"},
        RDW = {name = "Red Blood Cell Volume Distribution Width", system = "Hematologic System"},
        Hematocrit = {name = "Hematocrit", system = "Hematologic System"},
        MCV = {name = "Mean Corpuscular Volume", system = "Hematologic System"},
        MCH = {name = "Mean Corpuscular Hemoglobin", system = "Hematologic System"},
        MCHC = {name = "Mean Corpuscular Hemoglobin Concentration", system = "Hematologic System"},
        Hemoglobin = {name = "Hemoglobin", system = "Hematologic System"},
        WBC = {name = "White Blood Cell", system = "Hematologic System"},
        Granulocytes = {name = "Granulocytes", system = "Hematologic System"},
        Neutrophils = {name = "Neutrophils", system = "Hematologic System"},
        BasophilsEosinophils = {name = "Basophils, Eosinophils", system = "Hematologic System"},
        Lymphocytes = {name = "Lymphocytes", system = "Hematologic System"},
        Monocytes = {name = "Monocytes", system = "Hematologic System"},
        Platelet = {name = "Platelet", system = "Hematologic System"},
        MPV = {name = "Mean Platelet Volume", system = "Hematologic System"},
        PDW = {name = "Platelet Distribution Width", system = "Hematologic System"},
        ESR = {name = "Erythrocyte Sedimentation Rate", system = "Hematologic System"},
        DdimerFibrinogen = {name = "D-dimer, Fibrinogen", system = "Hematologic System"},
        Ferritin = {name = "Ferritin", system = "Hematologic System"},
        Transferrin = {name = "Transferrin", system = "Hematologic System"},
    
        -- Sensory System
        VisualAcc = {name = "Visual Accommodation", system = "Sensory System"},
        VisualReactTime = {name = "Visual Reaction Time", system = "Sensory System"},
        VisualAcuity = {name = "Visual Acuity", system = "Sensory System"},
        Hearing = {name = "Hearing", system = "Sensory System"},
        Vibrotactile = {name = "Vibrotactile", system = "Sensory System"},
        RetinalPhotos = {name = "Retinal Photos", system = "Sensory System"},
    
        -- Inflammatory Index
        CRP = {name = "C-Reactive Protein (CRP)", system = "Inflammatory Index"},
        CMVOptDensity = {name = "Cytomegalovirus Optical Density", system = "Inflammatory Index"},
        IL6 = {name = "Interleukin-6", system = "Inflammatory Index"},
        Pselectin = {name = "P-selectin", system = "Inflammatory Index"},
    
        -- Motion Index
        GripStrength = {name = "Grip Strength", system = "Motion Index"},
        VerticalJump = {name = "Vertical Jump", system = "Motion Index"},
        TUGTest = {name = "Timed Up and Go Test", system = "Motion Index"},
        ChairRiseTime = {name = "Chair Rise Time", system = "Motion Index"},
        PhysicalActivityWeek = {name = "1-Week Physical Activity", system = "Motion Index"},
    
        -- Body Morphology Index
        WaistCirc = {name = "Waist Circumference (WC)", system = "Body Morphology Index"},
        WaistHipRatio = {name = "Waist-to-Hip Ratio", system = "Body Morphology Index"},
        WaistHeightRatio = {name = "Waist-to-Height Ratio", system = "Body Morphology Index"},
        BMI = {name = "Body Mass Index (BMI)", system = "Body Morphology Index"},
        Weight = {name = "Weight", system = "Body Morphology Index"},
        Height = {name = "Height", system = "Body Morphology Index"},
        BodyFat = {name = "Body Fat", system = "Body Morphology Index"},
        LeanBodyMass = {name = "Lean Body Mass", system = "Body Morphology Index"},
        SoftLeanMass = {name = "Soft Lean Mass", system = "Body Morphology Index"},
    
        -- Genetic Index
        TelomereLength = {name = "Terminal Telomere Restriction Fragment", system = "Genetic Index"}
    }
    
    local rows = {
    	method = "Biological Age Estimation Method",
    	year = "Year"
    }
    
    -- Incorporate data directly into studies identified by PMID
    local studies = {
        PMID12345 = {
        	pmid = "12345",
            name = "Study1",
            method = "MLR",
            year = "1995",
            data = {
                SBP = "x",
                DBP = "x",
                HDL = "x",
                LDL = "x"
            }
        },
        PMID67890 = {
            pmid = "67890",
            method = "MLR",
            year = "1995",
            data = {
                SBP = "x",
                DBP = "x",
                HDL = "x",
                LDL = "x"
            }
        },
        PMID13579 = {
            pmid = "13579",
            method = "MLR",
            year = "1995",
            data = {
                SBP = "x",
                DBP = "x",
                HDL = "x",
                LDL = "x"
            }
        }
    }
    
    function p.createCrossTable()
        -- Start of the wiki table
        local wikitable = '{| class="wikitable"\n!'
    
        -- Column headers: Biomarker and System
        wikitable = wikitable .. ' System !! Biomarker'
        for _, study in pairs(studies) do
            wikitable = wikitable .. ' !! '  .. study.pmid
    	end
    	wikitable = wikitable .. '\n'
    
        for key, name in pairs(rows) do
            wikitable = wikitable .. '|-\n'
            wikitable = wikitable .. '| ' .. name .. ' || ' .. ''
            for _, study in pairs(studies) do
                local cellValue = study[key] or ""
    			wikitable = wikitable .. ' || ' .. cellValue
            end
    		wikitable = wikitable .. '\n'
    	end
    
        -- Generate rows for each biomarker
        for abbr, details in pairs(biomarkers) do
            wikitable = wikitable .. '|-\n'
            wikitable = wikitable .. '| '  .. details.system .. ' || ' .. details.name
            for _, study in pairs(studies) do
                -- Retrieve data value for the current cell, using the nested structure
                local cellValue = study.data[abbr] or ""
                wikitable = wikitable .. ' || ' .. cellValue
            end
    		wikitable = wikitable .. '\n'
        end
    
        -- End of the table
        wikitable = wikitable .. '\n|}'
    
        return wikitable
    end
    
    return p