Skip to content

Reduce unnecessary per-element checks #127

@araikes

Description

@araikes

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions