nichesphere.tl.PIC_BGdoubletsOEratios_parallel#
- nichesphere.tl.PIC_BGdoubletsOEratios_parallel(seed, adata, annot_col, target_pairs, downsample_cells=False, cell_list_downsample=None, downsampling_factor=6, pseudocount=1e-10)#
Generate one set of O/E ratios for cell type pair co-localization probabilities from randomly paired single cells. Running this function n times (e.g. via
get_PIC_BG_OEratios_DF) builds a per-pair empirical background distribution that can be used for significance testing in PIC-seq data or single-sample datasets.- Parameters:
seed (int) – Random seed for reproducibility.
adata (AnnData) – Singlets (scRNA-seq) anndata object.
annot_col (str) – Name of the cell type annotation column in
adata.obs.target_pairs (list or pd.Index) – Cell type pairs to evaluate (e.g.
colocPerSample.columns).downsample_cells (bool, default False) – Whether to downsample over-represented cell types before pairing. Useful when the gated singlets data does not reflect true in-tissue proportions.
cell_list_downsample (list or None, default None) – Cell types to downsample (used only when
downsample_cells=True).downsampling_factor (int, default 6) – Reduction factor passed to
downsample_class()(used only whendownsample_cells=True).pseudocount (float, default 1e-10) – Small value added to observed and expected counts before division to avoid division-by-zero or log(0) in downstream steps.
- Returns:
oe_ratios – O/E ratios for each pair in
target_pairs, indexed by pair name.- Return type:
pd.Series