pylimma.aver_arrays

pylimma.aver_arrays(x, id=None, weights=None)[source]

Average over technical-replicate columns.

Faithful port of R limma’s avearrays.default (matrix) and avearrays.EList (limma/R/avearrays.R:6-64). The unweighted path mirrors rowsum(..., reorder=FALSE): groups are ordered by first appearance (unique(id)), not sorted. The weighted path fits lm_fit(x, design=one_hot(id), weights=weights) and returns the coefficients.

avearrays.MAList is out of scope (two-colour data only).

For AnnData input, id defaults to adata.obs_names and a new AnnData is returned (obs axis collapsed to the unique ids). Because the output has a different number of samples than the input, in-place mutation via a layer is not possible, so this is the one AnnData-in path in pylimma that returns a value rather than None.

Parameters:

weights (ndarray | None)