spateo.preprocessing.aggregate#

Aggregate buckets of AnnData object by binning.

Module Contents#

Functions#

bin_adata(→ anndata.AnnData)

Aggregate cell-based AnnData by bin size. Cells within the same bin are aggregated together into one bucket.

spateo.preprocessing.aggregate.bin_adata(adata: anndata.AnnData, bin_size: int = 1, coords_key: str = 'spatial') anndata.AnnData[source]#

Aggregate cell-based AnnData by bin size. Cells within the same bin are aggregated together into one bucket.

Parameters:
adata

Input AnnData object

bin_size

Shrinking factor to be applied to spatial coordinates; the size of this factor dictates the size of the regions that will be combined into one pseudo-cell (larger -> generally higher number of cells in each bin).

coords_key

Key in .obsm where spatial coordinates are stored- bin coordinates will be used to update this array inplace.

Returns:

New AnnData object generated by this process.

Return type:

adata_binned