snapatac2.tl.aggregate_X#

snapatac2.tl.aggregate_X(adata, groupby=None, normalize=None, file=None)[source]#

Aggregate values in adata.X in a row-wise fashion.

Aggregate values in adata.X in a row-wise fashion. This is used to compute RPKM or RPM values stratified by user-provided groupings.

Parameters:
  • adata (AnnData | AnnDataSet) – The AnnData or AnnDataSet object.

  • groupby (str | list[str] | None) – Group the cells into different groups. If a str, groups are obtained from .obs[groupby].

  • normalize (Optional[Literal['RPM', 'RPKM']]) – normalization method: “RPM” or “RPKM”.

  • file (Path | None) – if provided, the results will be saved to a new h5ad file.

Returns:

If grouby is None, return a 1d array. Otherwise, return an AnnData object.

Return type:

np.ndarray | AnnData