harreman.hotspot.compute_local_autocorrelation#
- 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=device(type='cpu'), verbose=False)[source]#
Computes gene-level spatial autocorrelation statistics using spatial weights and centered gene expression values.
- Parameters:
adata (AnnData) – Annotated data object (AnnData). Requires obsp[“weights”] for the spatial graph.
layer_key (str or "use_raw", optional) – Key in adata.layers to use for expression data. Use “use_raw” to access adata.raw.
database_varm_key (str, optional) – Key in adata.varm used for filtering genes that are part of the transporter or ligand-receptor database.
model (str, optional) – Normalization model to use for centering gene expression. Options include “none”, “normal”, “bernoulli”, or “danb”.
genes (list, optional) – 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, optional (default: False)) – If True, restricts analysis to metabolic genes as defined for the selected species.
species ({"mouse", "human"}, optional (default: "mouse")) – Species used to select the correct metabolic gene list if use_metabolic_genes=True.
umi_counts_obs_key (str, optional) – Key in adata.obs with total UMI counts per cell. If None, inferred from the expression matrix.
permutation_test (bool, optional (default: False)) – Whether to compute an empirical p-value and null distribution by permuting the data.
M (int, optional (default: 1000)) – Number of permutations to perform if permutation_test is True.
seed (int, optional (default: 42)) – Random seed for permutation reproducibility.
check_analytic_null (bool, optional (default: False)) – Whether to evaluate Z-scores under an analytic null distribution using permutation Z-scores.
device (torch.device, optional) – PyTorch device to run computations on. Defaults to CUDA if available.
verbose (bool, optional (default: False)) – Whether to print progress and status messages.
- Returns:
The results are stored in adata.uns[“gene_autocorrelation_results”] as a DataFrame.
- Return type:
None