stlearn.tl.cci.run¶
- stlearn.tl.cci.run(adata: AnnData, lrs: ndarray, min_spots: int = 10, distance: float | None = None, n_pairs: int = 1000, n_cpus: int | None = None, use_label: str | None = None, adj_method: str = 'fdr_bh', pval_adj_cutoff: float = 0.05, min_expr: float = 0, save_bg: bool = False, neg_binom: bool = False, verbose: bool = True)[source]¶
Performs stLearn LR analysis.
- Parameters:
adata (AnnData) – The data object.
lrs (np.ndarray) – The LR pairs to score/test for enrichment (in format ‘L1_R1’).
min_spots (int) – Minimum number of spots with an LR score for an LR to be considered for further testing.
distance (int) – Distance to determine the neighbours (default [None] is immediately adjacent neighbours if using Visium), distance=0 means within spot (only for non-single-cell spatial data).
n_pairs (int) – Number of random pairs of genes to generate when creating the background distribution per LR pair; higher than more accurate p-value estimation.
n_cpus (int) – Number of threads to use or if None use os.cpu_count()
use_label (str) – The cell type deconvolution results to use in counting stored in adata.uns; if not specified only considered LR expression without cell heterogeneity.
adj_method (str) – Parsed to statsmodels.stats.multitest.multipletests for multiple hypothesis testing correction; see there for other options.
pval_adj_cutoff (float) – P-value below which LR is considered significant in spot neighbourhood.
min_expr (float) – Minimum gene expression of either L or R for spot to be considered to expression of either.
save_bg (bool) – Whether to save the background per LR pair; for method development only. Not recommended since huge memory.
neg_binom (bool) – Whether to fit a negative binomial distribution for all background scores generated across spots per LR after discretising the random scores. Can be extremely slow.
verbose (bool) – Whether print dialogue to user during run-time.
- Returns:
adata (AnnData)
Relevant information stored –
- adata.uns[‘lr_summary’]
Summary of significant spots detected per LR, the LRs listed in the index is the same order of LRs in the columns of results stored in adata.obsm below. Hence, the order of this must be maintained.
- adata.obsm
Additional keys are added; ‘lr_scores’, ‘lr_sig_scores’, ‘p_vals’, ‘p_adjs’, ‘-log10(p_adjs)’. All are numpy matrices, with columns referring to the LRs listed in adata.uns[‘lr_summary’]. ‘lr_scores’ is the raw scores, while ‘lr_sig_scores’ is the same except only for significant scores; non-significant scores are set to zero.
- adata.obsm[‘cci_het’]
Only if use_label specified; contains the counts of the cell types found per spot.