spcoral.model.registration

Contents

spcoral.model.registration#

spcoral.model.registration(adata_omics1, adata_omics2, alpha=1.0, beta=0.8, n_iter=10, method='affine', use_obsm='spatial', new_obsm='spatial_reg', random_state=2030)#

Perform spatial registration of two omics datasets using feature-guided optimal transport and anchor-based alignment.

This function aligns the spatial coordinates of adata_omics1 to adata_omics2 by first computing a fused Gromov-Wasserstein optimal transport plan that incorporates both modality-specific embeddings and shared features, then identifying anchor correspondences, and finally estimating a geometric transformation (e.g., affine) to warp the coordinates of omics1 into the space of omics2.

Parameters:
  • adata_omics1 (anndata.AnnData) – First omics AnnData object to be aligned (source). Must contain: - obsm['embedding']: modality-specific feature embedding. - obsm['share_feature']: cross-modality shared features. - obsm[use_obsm]: original spatial coordinates.

  • adata_omics2 (anndata.AnnData) – Second omics AnnData object (target/reference). Same requirements as above.

  • alpha (float, optional (default: 1.0)) – Weight for modality-specific features in the fused Gromov-Wasserstein distance.

  • beta (float, optional (default: 0.8)) – Weight for shared features in the fused distance.

  • n_iter (int, optional (default: 10)) – Number of iterations for anchor finding/refinement.

  • method (str, optional (default: 'affine')) – Type of geometric transformation to estimate (e.g., ‘affine’, ‘rigid’, ‘similarity’). Passed to the anchor-finding function.

  • use_obsm (str, optional (default: 'spatial')) – Key in .obsm containing the original spatial coordinates to be transformed.

  • new_obsm (str, optional (default: 'spatial_reg')) – Key under which the registered (transformed) coordinates will be stored in adata_omics1.

  • random_state (int, optional (default: 2030)) – Random seed for reproducibility in optimal transport.

Returns:

  • adata_omics1 : anndata.AnnData Copy of the input adata_omics1 with added obsm[new_obsm] containing registered coordinates.

  • registering_parameters : list List containing [T, omics1_index, omics2_index], where: - T : transformation matrix (or parameters). - omics1_index : indices of anchor spots in omics1. - omics2_index : indices of corresponding anchor spots in omics2.

Return type:

tuple