cellcharter.gr.enrichment

Contents

cellcharter.gr.enrichment#

cellcharter.gr.enrichment(adata, group_key, label_key, pvalues=False, n_perms=1000, log=True, observed_expected=False, copy=False)#

Compute the enrichment of label_key in group_key.

Parameters:
  • adata (AnnData) – Annotated data object.

  • group_key (str) – Key in anndata.AnnData.obs where groups are stored.

  • label_key (str) – Key in anndata.AnnData.obs where labels are stored.

  • pvalues (bool (default: False)) – If True, compute empirical p-values by permutation. It will result in a slower computation.

  • n_perms (int (default: 1000)) – Number of permutations to compute empirical p-values.

  • log (bool (default: True)) – If True use log2 fold change, otherwise use fold change.

  • observed_expected (bool (default: False)) – If True, return also the observed and expected proportions.

  • copy (bool (default: False)) – If True, return the result, otherwise save it to the adata object.

Return type:

DataFrame | tuple[DataFrame, DataFrame, DataFrame] | None

Returns:

If copy = True, returns a dict with the following keys:
  • 'enrichment' - the enrichment values.

  • 'pvalue' - the enrichment pvalues (if pvalues is True).

  • 'observed' - the observed proportions (if observed_expected is True).

  • 'expected' - the expected proportions (if observed_expected is True).

Otherwise, modifies the adata with the following keys:
  • anndata.AnnData.uns ['{group_key}_{label_key}_nhood_enrichment'] - the above mentioned dict.

  • anndata.AnnData.uns ['{group_key}_{label_key}_nhood_enrichment']['params'] - the parameters used.