nichesphere.tl.getExpectedColocProbsFromSCs

nichesphere.tl.getExpectedColocProbsFromSCs#

nichesphere.tl.getExpectedColocProbsFromSCs(cell_types, sc_adata=None, sample=None, sc_data_sampleCol=None, sc_adata_annotationCol=None, annot_series=None)#

Compute the expected co-localization probability of each cell type pair by multiplying cell type proportions derived from single-cell (singlets) data.

Two calling modes are supported:

  • AnnData mode – pass sc_adata, sample, sc_data_sampleCol, and sc_adata_annotationCol. The function extracts the annotation column for the requested condition internally.

  • Series mode – pass a pre-processed annot_series (e.g. after applying downsample_class()). This is useful when cell type frequencies need to be adjusted before computing expected probabilities.

Parameters:
  • cell_types (pd.Series or list) – Ordered list of cell types (same order as the co-localization data columns).

  • sc_adata (AnnData or None, default None) – Singlets anndata object (AnnData mode only).

  • sample (str or None, default None) – Condition/sample name to subset sc_adata (AnnData mode only).

  • sc_data_sampleCol (str or None, default None) – Column in sc_adata.obs indicating the condition (AnnData mode only).

  • sc_adata_annotationCol (str or None, default None) – Column in sc_adata.obs containing cell type labels (AnnData mode only).

  • annot_series (pd.Series or None, default None) – Pre-processed series of cell type labels, one entry per cell (Series mode only). Takes precedence over AnnData mode when provided.

Returns:

scCTpairsProbs – Expected co-localization probabilities per cell type pair. Cell type pairs as index, single column named 'count'.

Return type:

pd.DataFrame