Module:BiologicalAgeBiomarkers: Difference between revisions

    From Longevity Wiki
    No edit summary
    No edit summary
    Line 163: Line 163:
    system = "Body Morphology Index",
    system = "Body Morphology Index",
    data = {  
    data = {  
    {key = "WC", "Waist Circumference (WC)"},
    {key = "WC", name = "Waist Circumference (WC)"},
    {key = "WaistHipRatio", name = "Waist-to-Hip Ratio"},
    {key = "WaistHipRatio", name = "Waist-to-Hip Ratio"},
    {key = "WaistHeightRatio", name = "Waist-to-Height Ratio"},
    {key = "WaistHeightRatio", name = "Waist-to-Height Ratio"},

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