mantispy.tl.aggregate

Contents

mantispy.tl.aggregate#

mantispy.tl.aggregate(adata, by=('Metadata_Plate', 'Metadata_Well'), func='median', min_cells=10, layer=None)[source]#

Aggregate adata to one profile per group.

Parameters:
  • adata (AnnData) – Single-cell object to aggregate.

  • by (Sequence[str] (default: ('Metadata_Plate', 'Metadata_Well'))) – Columns defining a profile. The default is one profile per well.

  • func (str (default: 'median')) – "median" (the pycytominer default) or "mean".

  • min_cells (int (default: 10)) – Groups with fewer cells than this are dropped.

  • layer (str | None (default: None)) – Aggregate this layer instead of X.

Return type:

AnnData

Returns:

A new AnnData with one row per group. var is carried over unchanged; obs holds the grouping columns, Metadata_CellCount, and every other Metadata_ column that is constant within every group.

Notes

This uses mantispy’s own NaN-skipping kernel rather than scanpy.get.aggregate(), which propagates NaN and is measurably slower on both mean and median.