cascade.data.aggregate_obs

cascade.data.aggregate_obs(adata, by, X_agg=None, obs_agg=None, obsm_agg=None, layers_agg=None)[source]

Aggregate obs in a given dataset by certain categories

Parameters:
  • adata (AnnData) – Dataset to be aggregated

  • by (str) – Specify a column in obs used for aggregation, must be discrete.

  • X_agg (str | None) – Aggregation function for X, must be one of {"sum", "mean", ``None}``. Setting to None discards the adata.X matrix.

  • obs_agg (Mapping[str, str] | None) – Aggregation methods for obs, indexed by obs columns, must be one of {"sum", "mean", "majority"}, where "sum" and "mean" are for continuous data, and "majority" is for discrete data. Fields not specified will be discarded.

  • obsm_agg (Mapping[str, str] | None) – Aggregation methods for obsm, indexed by obsm keys, must be one of {"sum", "mean"}. Fields not specified will be discarded.

  • layers_agg (Mapping[str, str] | None) – Aggregation methods for layers, indexed by layer keys, must be one of {"sum", "mean"}. Fields not specified will be discarded.

Return type:

AnnData

Returns:

Aggregated dataset