enrichmap.tl.score

Contents

enrichmap.tl.score#

enrichmap.tl.score(adata: AnnData, gene_set: list | dict | None = None, gene_weights: dict | None = None, score_key: str | list | None = None, spatial_key: str | None = 'spatial', n_neighbors: int = 6, smoothing: bool = True, correct_spatial_covariates: bool = True, batch_key: str | None = None) None#

Compute spatially smoothed and spatially corrected gene set enrichment scores for one or more gene signatures.

Parameters:
  • adata (AnnData) – Annotated data matrix, containing expression values and spatial coordinates in obsm.

  • gene_set (list or dict or None) – Gene set(s) to be scored. If a list is provided, it is interpreted as a single gene signature. If a dict is provided, keys are signature names and values are lists of gene symbols. If None, gene_weights must be provided and gene sets will be inferred from the keys of gene_weights.

  • gene_weights (dict, optional) – Dictionary mapping signature names to dictionaries of gene weights (default is None). If None, gene weights are inferred automatically. If provided, gene_set is overridden to match the keys.

  • score_key (str, list, or None, optional) – Name or list of names to assign to the gene signature(s) if gene_set is provided as a list. Ignored if gene_set is already a dictionary.

  • spatial_key (str) – Key in adata.obsm containing spatial coordinates used for spatial covariate correction. By default, it is set to “spatial”.

  • n_neighbors (int, default 6) – Number of nearest spatial neighbours used for smoothing.

  • smoothing (bool, default True) – Whether to perform spatial smoothing of signature scores.

  • correct_spatial_covariates (bool, default True) – Whether to correct scores for spatial covariates using a GAM.

  • batch_key (str or None, optional) – Column in adata.obs indicating batch labels.

Returns:

Scores are stored in adata.obs and gene contributions in adata.uns[“gene_contributions”].

Return type:

None