Module:BiologicalAgeBiomarkers: Difference between revisions
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
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"} | ||
} | |||
local rows = { | |||
method = "Biological Age Estimation Method", | |||
year = "Year" | |||
} | } | ||
Line 12: | Line 17: | ||
local studies = { | local studies = { | ||
PMID12345 = { | PMID12345 = { | ||
pmid = 12345, | |||
name = "Study1", | name = "Study1", | ||
method = "MLR", | |||
year = "1995", | |||
data = { | data = { | ||
SBP = " | SBP = "x", | ||
DBP = " | DBP = "x", | ||
HDL = " | HDL = "x", | ||
LDL = " | LDL = "x" | ||
} | } | ||
}, | }, | ||
PMID67890 = { | PMID67890 = { | ||
name = " | name = 67890, | ||
method = "MLR", | |||
year = "1995", | |||
data = { | data = { | ||
SBP = " | SBP = "x", | ||
DBP = " | DBP = "x", | ||
HDL = " | HDL = "x", | ||
LDL = " | LDL = "x" | ||
} | } | ||
}, | }, | ||
PMID13579 = { | PMID13579 = { | ||
pmid = 13579, | |||
method = "MLR", | |||
year = "1995", | |||
data = { | data = { | ||
SBP = " | SBP = "x", | ||
DBP = " | DBP = "x", | ||
HDL = " | HDL = "x", | ||
LDL = " | LDL = "x" | ||
} | } | ||
} | } | ||
Line 47: | Line 59: | ||
wikitable = wikitable .. ' System !! Biomarker' | wikitable = wikitable .. ' System !! Biomarker' | ||
for _, study in pairs(studies) do | for _, study in pairs(studies) do | ||
wikitable = wikitable .. ' !! ' .. study.name | 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 | -- Generate rows for each biomarker | ||
for abbr, details in pairs(biomarkers) do | for abbr, details in pairs(biomarkers) do | ||
wikitable = wikitable .. ' | wikitable = wikitable .. '|-\n' | ||
wikitable = wikitable .. details.system .. ' || ' .. details.name | |||
for _, study in pairs(studies) do | for _, study in pairs(studies) do | ||
-- Retrieve data value for the current cell, using the nested structure | -- Retrieve data value for the current cell, using the nested structure | ||
local cellValue = study.data[abbr] or " | local cellValue = study.data[abbr] or "" | ||
wikitable = wikitable .. ' || ' .. cellValue | wikitable = wikitable .. ' || ' .. cellValue | ||
end | end | ||
wikitable = wikitable .. '\n' | |||
end | end | ||
Revision as of 01:34, 19 February 2024
local p = {}
-- Define biomarkers with their long form and system
local biomarkers = {
SBP = {name = "Systolic Blood Pressure (SBP)", system = "Cardiovascular System"},
DBP = {name = "Diastolic Blood Pressure (DBP)", system = "Cardiovascular System"},
HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"}
}
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 = {
name = 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