STAVAG.DVG_detection

STAVAG.DVG_detection(adata, coords, sps=False, threshold=0.05, num_perm=1)[source]

Detect Directionally Variable Genes (DVGs) using regression on spatial coordinates.

Parameters:
  • adata (AnnData) – AnnData with expression matrix adata.X and gene names adata.var.index.

  • coords (ndarray) – Spatial coordinates of cells with shape (n_cells, n_dim). For example two columns for x and y or three columns for x y z.

  • sps (bool, optional) – If True, compute STAVAG priority scores by comparing observed importances with random baselines. Defaults to False.

  • threshold (float, optional) – Importance threshold used when selecting DVGs. Larger values keep more genes. Defaults to 0.05.

  • num_perm (int, optional) – Number of permutations used to build an empirical null distribution of feature importances. - If 1: keep the original single-permutation behavior. - If > 1: must be >= 100; empirical p-values are computed for each gene.

Returns:

Dictionary containing top important genes per coordinate axis (e.g., ‘x’, ‘y’, ‘z’), filtered with the threshold.

  • For num_perm == 1: same structure as before (with SPS scores if sps=True).

  • For num_perm > 1: each DataFrame contains columns [‘Feature’, ‘Importance’, ‘null_mean’, ‘pval’] and is filtered by p-value (<= threshold).

Return type:

Dict[str, DataFrame]