ocelli.tl.zscores#
- ocelli.tl.zscores(adata: AnnData, markers: list, x: str | None = None, vmin: float = -5.0, vmax: float = 5.0, out: str = 'mean_z_scores', n_jobs: int = -1, copy: bool = False)#
Gene signature mean z-scores
Computes mean z-scores for a specified gene signature based on marker indices. The z-scores are scaled to fit within the range (vmin, vmax) before being averaged for each cell.
Note
Ensure that the count matrix has been normalized and log-transformed before using this function.
- Parameters:
adata (anndata.AnnData) – The annotated data matrix.
markers (list) – List of column indices corresponding to marker genes in adata.X or adata.obsm[x].
x (str or None) – Key in adata.obsm storing the data matrix for z-score computation. If None, adata.X is used. (default: None)
vmin (float) – Minimum value to clip the z-scores before averaging. (default: -5.0)
vmax (float) – Maximum value to clip the z-scores before averaging. (default: 5.0)
out (str) – Key in adata.obs where the mean z-scores will be stored. (default: ‘mean_z_scores’)
n_jobs (int) – Number of parallel jobs to use. If -1, all available CPUs are used. (default: -1)
copy (bool) – Whether to return a copy of adata. If False, updates are made in-place. (default: False)
- Returns:
If copy=False: Updates adata with the mean z-scores stored in adata.obs[out].
If copy=True: Returns a modified copy of adata with the mean z-scores.
- Return type:
anndata.AnnData or None
- Example:
import ocelli as oci from anndata import AnnData import numpy as np # Example data adata = AnnData(X=np.random.rand(100, 50)) # Indices of marker genes markers = [0, 5, 10] # Compute mean z-scores oci.tl.zscores(adata, markers=markers, vmin=-3, vmax=3, out='signature_zscores')