BAITS.st.gr.aggregate_neighbors#
- BAITS.st.gr.aggregate_neighbors(adata, n_layers, aggregations='mean', connectivity_key='spatial_connectivities', use_rep='X_pca', sample_key='sample', out_key='X_cellcharter', copy=False)#
Aggregate the features from each neighborhood layers and concatenate them
- Parameters:
adata (AnnData) – The annotated data matrix (single-cell dataset in AnnData format).
n_layers (int or list) – The number of neighborhood layers to aggregate. If an integer is given, it is converted into a list ranging from 0 to
n_layers.aggregations (str or list, default="mean") – The type of aggregation(s) to perform (e.g., “mean”, “sum”).
connectivity_key (str, optional) – Key in
adata.obspthat contains the spatial connectivity matrix.use_rep (str, optional) – Key in
adata.obsmthat specifies which representation (feature matrix) to use. IfNone, the function usesadata.X.sample_key (str, optional) – Key in
adata.obsthat identifies sample/grouping information. IfNone, all cells are considered together.out_key (str, default="X_cellcharter") – Key under which the aggregated features are stored in
adata.obsm.copy (bool, default=False) – If True, returns the aggregated feature matrix instead of modifying
adata.
- Returns:
If
copyis True, returns the aggregated feature matrix as a numpy array or sparse matrix.
Otherwise, modifies
adata.obsmin place, storing the aggregated matrix underout_key.