spateo.alignment.methods.deprecated_morpho_sparse_utils ======================================================= .. py:module:: spateo.alignment.methods.deprecated_morpho_sparse_utils Attributes ---------- .. autoapisummary:: spateo.alignment.methods.deprecated_morpho_sparse_utils.nx_torch spateo.alignment.methods.deprecated_morpho_sparse_utils._cat spateo.alignment.methods.deprecated_morpho_sparse_utils._dot spateo.alignment.methods.deprecated_morpho_sparse_utils._split spateo.alignment.methods.deprecated_morpho_sparse_utils._where spateo.alignment.methods.deprecated_morpho_sparse_utils._repeat_interleave Functions --------- .. autoapisummary:: spateo.alignment.methods.deprecated_morpho_sparse_utils.calc_distance spateo.alignment.methods.deprecated_morpho_sparse_utils.calc_P_related spateo.alignment.methods.deprecated_morpho_sparse_utils.get_optimal_R_sparse spateo.alignment.methods.deprecated_morpho_sparse_utils._init_guess_sigma2 spateo.alignment.methods.deprecated_morpho_sparse_utils._init_guess_beta2 spateo.alignment.methods.deprecated_morpho_sparse_utils._construct_label_mask spateo.alignment.methods.deprecated_morpho_sparse_utils._dense_to_sparse spateo.alignment.methods.deprecated_morpho_sparse_utils._SparseTensor spateo.alignment.methods.deprecated_morpho_sparse_utils._cos_similarity spateo.alignment.methods.deprecated_morpho_sparse_utils._cosine_distance_backend spateo.alignment.methods.deprecated_morpho_sparse_utils._cos_similarity spateo.alignment.methods.deprecated_morpho_sparse_utils._dist spateo.alignment.methods.deprecated_morpho_sparse_utils.torch_like_split spateo.alignment.methods.deprecated_morpho_sparse_utils._sort Module Contents --------------- .. py:function:: calc_distance(X_A: Union[numpy.ndarray, torch.Tensor], X_B: Union[numpy.ndarray, torch.Tensor], metric: str = 'euc', batch_capacity: int = 1, use_sparse: bool = False, sparse_method: str = 'topk', threshold: Union[int, float] = 100, return_mask: bool = False, save_to_cpu: bool = False, **kwargs) .. py:function:: calc_P_related(XnAHat: Union[numpy.ndarray, torch.Tensor], XnB: Union[numpy.ndarray, torch.Tensor], X_A: Union[numpy.ndarray, torch.Tensor], X_B: Union[numpy.ndarray, torch.Tensor], sigma2: Union[int, float, numpy.ndarray, torch.Tensor], sigma2_robust: Union[int, float, numpy.ndarray, torch.Tensor], beta2: Union[int, float, numpy.ndarray, torch.Tensor], spatial_outlier, col_mul=None, batch_capacity: int = 1, dissimilarity: str = 'kl', labelA: Optional[pandas.Series] = None, labelB: Optional[pandas.Series] = None, label_transfer_prior: Optional[dict] = None, top_k: int = 1024) .. py:function:: get_optimal_R_sparse(coordsA: Union[numpy.ndarray, torch.Tensor], coordsB: Union[numpy.ndarray, torch.Tensor], P: Union[numpy.ndarray, torch.Tensor, torch.sparse_coo_tensor], R_init: Union[numpy.ndarray, torch.Tensor]) Get the optimal rotation matrix R :param coordsA: The first input matrix with shape n x d :type coordsA: Union[np.ndarray, torch.Tensor] :param coordsB: The second input matrix with shape n x d :type coordsB: Union[np.ndarray, torch.Tensor] :param P: The optimal transport matrix with shape n x n :type P: Union[np.ndarray, torch.Tensor] :returns: The optimal rotation matrix R with shape d x d :rtype: Union[np.ndarray, torch.Tensor] .. py:function:: _init_guess_sigma2(XA, XB, subsample=2000) .. py:function:: _init_guess_beta2(nx, XA, XB, dissimilarity='kl', partial_robust_level=1, beta2=None, beta2_end=None, subsample=2000) .. py:function:: _construct_label_mask(nx, labelA, labelB, label_transfer_prior, type_as) .. py:function:: _dense_to_sparse(mat: Union[numpy.ndarray, torch.Tensor], sparse_method: str = 'topk', threshold: Union[int, float] = 100, axis: int = 0, descending=False) .. py:function:: _SparseTensor(nx, row, col, value, sparse_sizes) .. py:function:: _cos_similarity(mat1: Union[numpy.ndarray, torch.Tensor], mat2: Union[numpy.ndarray, torch.Tensor]) .. py:function:: _cosine_distance_backend(X: Union[numpy.ndarray, torch.Tensor], Y: Union[numpy.ndarray, torch.Tensor], eps: float = 1e-08) -> Union[numpy.ndarray, torch.Tensor] Compute the pairwise cosine similarity between all pairs of samples in matrices X and Y. :param X: Matrix with shape (N, D), where each row represents a sample. :type X: np.ndarray or torch.Tensor :param Y: Matrix with shape (M, D), where each row represents a sample. :type Y: np.ndarray or torch.Tensor :param eps: A small value to avoid division by zero. Default is 1e-8. :type eps: float, optional :returns: Pairwise cosine similarity matrix with shape (N, M). :rtype: np.ndarray or torch.Tensor :raises AssertionError: If the number of features in X and Y do not match. .. py:function:: _cos_similarity(mat1: Union[numpy.ndarray, torch.Tensor], mat2: Union[numpy.ndarray, torch.Tensor]) .. py:function:: _dist(mat1: Union[numpy.ndarray, torch.Tensor], mat2: Union[numpy.ndarray, torch.Tensor], metric: str = 'euc') -> Union[numpy.ndarray, torch.Tensor] .. py:data:: nx_torch .. py:data:: _cat .. py:data:: _dot .. py:data:: _split .. py:function:: torch_like_split(arr, size, dim=0) .. py:data:: _where .. py:data:: _repeat_interleave .. py:function:: _sort(nx, arr, axis=-1, descending=False)