mantispy.tl.enrich

Contents

mantispy.tl.enrich#

mantispy.tl.enrich(adata, net=None, by='feature_group', method='ulm', top_fraction=0.05, copy=False, **decoupler_kwargs)#

Score every profile against every feature set.

Parameters:
  • adata (AnnData) – Profiles to score. Normalize first, since the methods use the values as given.

  • net (DataFrame | None (default: None)) – A decoupler network with source, target and weight, for example prior-knowledge sets. Built from by when omitted.

  • by (str | Sequence[str] (default: 'feature_group')) – Passed to feature_sets() when net is not given.

  • method (str (default: 'ulm')) – "ulm" fits a linear model per set and is the usual choice; "mlm" fits all sets jointly, which handles overlapping sets; "ora" is an over-representation test on the extremes.

  • top_fraction (float (default: 0.05)) – Fraction of features, ranked by value, that method="ora" counts as extreme. The default 0.05 tests the top twentieth against the rest. Ignored when n_up is passed, and by "ulm" and "mlm", which use every feature.

  • copy (bool (default: False)) – Return a modified copy instead of mutating in place.

  • decoupler_kwargs (Any) – Passed through to decoupler, e.g. tmin for the smallest usable set.

Return type:

AnnData | None

Returns:

None, or the modified copy. decoupler writes obsm["score_<method>"] and obsm["padj_<method>"], both frames indexed by set name.

Raises:

ValueErrormethod is not one of METHODS, no feature set could be built from by, or top_fraction is outside (0, 1).