paste3.paste.center_ot
- paste3.paste.center_ot(feature_matrix, coeff_matrix, slices, center_coordinates, common_genes, alpha, use_gpu, exp_dissim_metric='kl', norm=False, pi_inits=None, spot_weights=None, numItermax=200)[source]
Computes the optimal mappings \(\Pi^{(1)}, \ldots, \Pi^{(t)}\) given W (specified features) and H (coefficient matrix) by solving the pairwise slice alignment problem between the center slice and each slices separately
- Parameters:
feature_matrix (np.ndarray) -- The matrix representing features extracted from the initial slice.
coeff_matrix (np.ndarray) -- The matrix representing the coefficients corresponding to the features.
slices (List[AnnData]) -- A list of AnnData objects representing the slices to be aligned with the center slice.
center_coordinates (np.ndarray) -- Spatial coordinates of the center slice.
common_genes (Index) -- Index of common genes shared among all slices for alignment.
alpha (float) -- Regularization parameter balancing transcriptional dissimilarity and spatial distance among aligned spots. Setting alpha = 0 uses only transcriptional information, while alpha = 1 uses only spatial coordinates.
use_gpu (bool) -- Whether to use GPU for computations. If True but no GPU is available, will default to CPU.
exp_dissim_metric (str, default="kl") -- Metric used to compute the expression dissimilarity between slices. Options include "euclidean" and "kl".
norm (bool, default=False) -- If True, normalizes spatial distances.
pi_inits (Optional[List[np.ndarray]], default=None) -- Initial transport plans for each slice. If None, it will be computed.
spot_weights (Optional[List[float]], default=None) -- Weights for individual spots in each slice. If None, uniform distribution is used.
numItermax (int, default=200) -- Maximum number of iterations allowed for the optimization process.
- Returns:
A tuple containing: - pis : List[np.ndarray]
List of optimal transport plans for aligning each slice to the center slice.
- lossesnp.ndarray
Array of loss values corresponding to each slice alignment.
- Return type:
Tuple[List[np.ndarray], np.ndarray]