scviva.tools.harreman.hotspot.compute_local_autocorrelation#

scviva.tools.harreman.hotspot.compute_local_autocorrelation(adata, layer_key=None, database_varm_key=None, model=None, genes=None, use_metabolic_genes=False, species='mouse', umi_counts_obs_key=None, permutation_test=False, M=1000, seed=42, check_analytic_null=False, device='auto', accelerator='auto', verbose=False)[source]#

Compute gene-level spatial autocorrelation using spatial weights and centered expression.

Parameters:
adata AnnData

Annotated data object (AnnData). Requires obsp["weights"] for the spatial graph.

layer_key Union[Literal['use_raw'], str, None]

Key in adata.layers to use for expression data. Use “use_raw” to access adata.raw.

database_varm_key str | None

Key in adata.varm used for filtering genes that are part of the transporter or ligand-receptor database.

model str | None

Normalization model to use for centering gene expression. Options include “none”, “normal”, “bernoulli”, or “danb”.

genes list | None

List of gene names to include in the analysis. If None, all genes are used or selected via metabolic/pathway filters.

use_metabolic_genes bool

If True, restricts analysis to metabolic genes as defined for the selected species.

species Union[Literal['mouse'], Literal['human'], None]

Species used to select the correct metabolic gene list if use_metabolic_genes=True.

umi_counts_obs_key str | None

Key in adata.obs with total UMI counts per cell. If None, inferred from the expression matrix.

permutation_test bool

Whether to compute an empirical p-value and null distribution by permuting the data.

M int | None

Number of permutations to perform if permutation_test is True.

seed int | None

Random seed for permutation reproducibility.

check_analytic_null bool

Whether to evaluate Z-scores under an analytic null distribution using permutation Z-scores.

device int | str | device

Device to use for computation. If "auto" or a device index, this is resolved with scvi.model._utils.parse_device_args().

accelerator str

Accelerator type to use when resolving device.

verbose bool

Whether to print progress and status messages.

Returns:

None The results are stored in adata.uns["gene_autocorrelation_results"] as a DataFrame.