spatialvi.external.Harreman#

class spatialvi.external.Harreman(adata, metabolic_genes=None, spatial_key='spatial', labels_key=None, n_neighbors=20)[source]#

Bases: object

Harreman model for metabolic exchange inference.

Harreman infers metabolic exchange between spatially proximal cells by analyzing correlations between metabolic gene expression and spatial proximity patterns.

Parameters:
  • adata (AnnData) – AnnData object with spatial transcriptomics data.

  • metabolic_genes (Sequence[str] | None) – List of metabolic genes to analyze. If None, uses a default set of metabolic pathway genes.

  • spatial_key (str) – Key in obsm for spatial coordinates.

  • labels_key (str | None) – Key in obs for cell type labels.

  • n_neighbors (int) – Number of spatial neighbors to consider.

  • adata (AnnData)

  • metabolic_genes (Sequence[str] | None)

  • spatial_key (str)

  • labels_key (str | None)

  • n_neighbors (int)

Examples

>>> import spatialvi
>>> adata = spatialvi.data.synthetic_spatial()
>>> model = Harreman(adata, labels_key="cell_type")
>>> model.fit()
>>> exchanges = model.get_metabolic_exchanges()
__init__(adata, metabolic_genes=None, spatial_key='spatial', labels_key=None, n_neighbors=20)[source]#
Parameters:

Methods

__init__(adata[, metabolic_genes, ...])

fit([n_permutations, correlation_method])

Fit the Harreman model.

get_cell_type_exchanges([min_cells])

Get metabolic exchanges between cell types.

get_metabolic_exchanges([fdr_threshold])

Get significant metabolic exchange genes.

to_adata()

Store results in AnnData object.

fit(n_permutations=100, correlation_method='spearman')[source]#

Fit the Harreman model.

Parameters:
  • n_permutations (int) – Number of permutations for null distribution.

  • correlation_method (Literal['pearson', 'spearman']) – Correlation method to use.

  • n_permutations (int)

  • correlation_method (Literal['pearson', 'spearman'])

Return type:

Harreman

Returns:

Self.

get_metabolic_exchanges(fdr_threshold=0.05)[source]#

Get significant metabolic exchange genes.

Parameters:
  • fdr_threshold (float) – FDR threshold for significance.

  • fdr_threshold (float)

Return type:

DataFrame

Returns:

DataFrame with exchange scores and statistics.

get_cell_type_exchanges(min_cells=10)[source]#

Get metabolic exchanges between cell types.

Parameters:
  • min_cells (int) – Minimum cells per cell type.

  • min_cells (int)

Return type:

DataFrame

Returns:

DataFrame with cell type pair exchanges.

to_adata()[source]#

Store results in AnnData object.

Return type:

None