Each of the analyseOneElement functions performs a long chain of operations on a per-element basis (example for analyseOneElement.lm below)
| Step |
Operation |
| 1 |
HDF5 row read (DelayedArray subsetting) |
| 2 |
is.finite() check across all subjects |
| 3 |
Collision checks between scalar names and phenotype columns |
| 4 |
Formula variable parsing (all.vars(), as.character(formula[[2]])) |
| 5 |
Cross-scalar predictor detection and source alignment via match() |
| 6 |
Data frame construction and subsetting |
| 7 |
stats::lm() model fitting |
| 8 |
broom::tidy() and broom::glance() extraction |
Steps 3–5 are repeated identically for every element despite being invariant across the data. The formula parsing, collision checks, and scalar predictor detection produce the same results every time, yet are recomputed millions of times.
Consider precomputing the model fitting context before looping and passing the context to the analyze functions.
Each of the
analyseOneElementfunctions performs a long chain of operations on a per-element basis (example foranalyseOneElement.lmbelow)is.finite()check across all subjectsall.vars(),as.character(formula[[2]]))match()stats::lm()model fittingbroom::tidy()andbroom::glance()extractionSteps 3–5 are repeated identically for every element despite being invariant across the data. The formula parsing, collision checks, and scalar predictor detection produce the same results every time, yet are recomputed millions of times.
Consider precomputing the model fitting context before looping and passing the context to the
analyzefunctions.