src.paste.center_align

center_align(A, slices, lmbda=None, alpha=0.1, n_components=15, threshold=0.001, max_iter=10, dissimilarity='kl', norm=False, random_seed=None, pis_init=None, distributions=None, backend=<ot.backend.NumpyBackend object>, use_gpu=False, verbose=False, gpu_verbose=True)[source]

Computes center alignment of slices.

Parameters
  • A (AnnData) – Slice to use as the initialization for center alignment; Make sure to include gene expression and spatial information.

  • slices (List[AnnData]) – List of slices to use in the center alignment.

  • lmbda (array-like, optional) – List of probability weights assigned to each slice; If None, use uniform weights.

  • alpha (float) – Alignment tuning parameter. Note: 0 <= alpha <= 1.

  • n_components (int) – Number of components in NMF decomposition.

  • threshold (float) – Threshold for convergence of W and H during NMF decomposition.

  • max_iter (int) – Maximum number of iterations for our center alignment algorithm.

  • dissimilarity (str) – Expression dissimilarity measure: 'kl' or 'euclidean'.

  • norm (bool) – If True, scales spatial distances such that neighboring spots are at distance 1. Otherwise, spatial distances remain unchanged.

  • random_seed (Optional[int]) – Set random seed for reproducibility.

  • pis_init (Optional[List[ndarray]]) – Initial list of mappings between ‘A’ and ‘slices’ to solver. Otherwise, default will automatically calculate mappings.

  • distributions (List[array-like], optional) – Distributions of spots for each slice. Otherwise, default is uniform.

  • backend – Type of backend to run calculations. For list of backends available on system: ot.backend.get_backend_list().

  • use_gpu (bool) – If True, use gpu. Otherwise, use cpu. Currently we only have gpu support for Pytorch.

  • verbose (bool) – If True, FGW-OT is verbose.

  • gpu_verbose (bool) – If True, print whether gpu is being used to user.

Return type

Tuple[AnnData, List[ndarray]]

Returns

  • Inferred center slice with full and low dimensional representations (W, H) of the gene expression matrix.

  • List of pairwise alignment mappings of the center slice (rows) to each input slice (columns).