omicverse.metabol.mixed_model#
- omicverse.metabol.mixed_model(adata, *, formula, groups, re_formula='1', term=None, layer=None)[source]#
Per-feature
statsmodels.MixedLMfit.Fits
y ~ <formula>for each metabolite withgroups=<groups>defining the random-effect grouping variable (e.g. patient ID).- Parameters:
formula (
str) – Patsy-style formula without they ~prefix. Categorical effects, interactions (a * b), and numerics all work.groups (
str) – Name of theadata.obscolumn carrying the random-effect grouping labels. Usually patient / subject ID.re_formula (
Optional[str] (default:'1')) – Random-effect formula."1"(default) = random intercept. Use"1 + time"for random slopes.term (
Optional[str] (default:None)) – If given, return a short-format table with one row per feature for this specific fixed-effect term (matches themetabol.differential()schema:stat / pvalue / padj). IfNone, return a long-format table with one row per(feature, term)pair, excluding the intercept and variance components.layer (
Optional[str] (default:None)) – AnnData layer name (defaultNone→adata.X).
- Returns:
Long format (default): columns
feature, term, coef, se, stat, pvalue, padj. Short format (term=...): indexed by feature withcoef, se, stat, pvalue, padj.- Return type:
pd.DataFrame