stereo.algorithm.paste.center_align#

stereo.algorithm.paste.center_align(initial_slice, slices, lmbda=None, alpha=0.1, n_components=15, threshold=0.001, max_iter=10, nmf_max_iter=200, 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:
  • initial_slice (StereoExpData) – Slice to use as the initialization for center alignment; Make sure to include gene expression and spatial information.

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

  • optional) (distributions (List[array-like],) – 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.

  • 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[StereoExpData, 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).