spateo.alignment.methods.deprecated_morpho_sparse_utils

Attributes

Functions

calc_distance(X_A, X_B[, metric, batch_capacity, ...])

calc_P_related(XnAHat, XnB, X_A, X_B, sigma2, ...[, ...])

get_optimal_R_sparse(coordsA, coordsB, P, R_init)

Get the optimal rotation matrix R

_init_guess_sigma2(XA, XB[, subsample])

_init_guess_beta2(nx, XA, XB[, dissimilarity, ...])

_construct_label_mask(nx, labelA, labelB, ...)

_dense_to_sparse(mat[, sparse_method, threshold, ...])

_SparseTensor(nx, row, col, value, sparse_sizes)

_cos_similarity(mat1, mat2)

_cosine_distance_backend(→ Union[numpy.ndarray, ...)

Compute the pairwise cosine similarity between all pairs of samples in matrices X and Y.

_cos_similarity(mat1, mat2)

_dist(→ Union[numpy.ndarray, torch.Tensor])

torch_like_split(arr, size[, dim])

_sort(nx, arr[, axis, descending])

Module Contents

spateo.alignment.methods.deprecated_morpho_sparse_utils.calc_distance(X_A: numpy.ndarray | torch.Tensor, X_B: numpy.ndarray | torch.Tensor, metric: str = 'euc', batch_capacity: int = 1, use_sparse: bool = False, sparse_method: str = 'topk', threshold: int | float = 100, return_mask: bool = False, save_to_cpu: bool = False, **kwargs)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils.get_optimal_R_sparse(coordsA: numpy.ndarray | torch.Tensor, coordsB: numpy.ndarray | torch.Tensor, P: numpy.ndarray | torch.Tensor | torch.sparse_coo_tensor, R_init: numpy.ndarray | torch.Tensor)[source]

Get the optimal rotation matrix R

Parameters:
coordsA Union[np.ndarray, torch.Tensor]

The first input matrix with shape n x d

coordsB Union[np.ndarray, torch.Tensor]

The second input matrix with shape n x d

P Union[np.ndarray, torch.Tensor]

The optimal transport matrix with shape n x n

Returns:

The optimal rotation matrix R with shape d x d

Return type:

Union[np.ndarray, torch.Tensor]

spateo.alignment.methods.deprecated_morpho_sparse_utils._init_guess_sigma2(XA, XB, subsample=2000)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._init_guess_beta2(nx, XA, XB, dissimilarity='kl', partial_robust_level=1, beta2=None, beta2_end=None, subsample=2000)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._construct_label_mask(nx, labelA, labelB, label_transfer_prior, type_as)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._dense_to_sparse(mat: numpy.ndarray | torch.Tensor, sparse_method: str = 'topk', threshold: int | float = 100, axis: int = 0, descending=False)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._SparseTensor(nx, row, col, value, sparse_sizes)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._cos_similarity(mat1: numpy.ndarray | torch.Tensor, mat2: numpy.ndarray | torch.Tensor)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._cosine_distance_backend(X: numpy.ndarray | torch.Tensor, Y: numpy.ndarray | torch.Tensor, eps: float = 1e-08) numpy.ndarray | torch.Tensor[source]

Compute the pairwise cosine similarity between all pairs of samples in matrices X and Y.

Parameters:
X np.ndarray or torch.Tensor

Matrix with shape (N, D), where each row represents a sample.

Y np.ndarray or torch.Tensor

Matrix with shape (M, D), where each row represents a sample.

eps float, optional

A small value to avoid division by zero. Default is 1e-8.

Returns:

Pairwise cosine similarity matrix with shape (N, M).

Return type:

np.ndarray or torch.Tensor

Raises:

AssertionError – If the number of features in X and Y do not match.

spateo.alignment.methods.deprecated_morpho_sparse_utils._cos_similarity(mat1: numpy.ndarray | torch.Tensor, mat2: numpy.ndarray | torch.Tensor)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._dist(mat1: numpy.ndarray | torch.Tensor, mat2: numpy.ndarray | torch.Tensor, metric: str = 'euc') numpy.ndarray | torch.Tensor[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils.nx_torch[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._cat[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._dot[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._split[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils.torch_like_split(arr, size, dim=0)[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._where[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._repeat_interleave[source]
spateo.alignment.methods.deprecated_morpho_sparse_utils._sort(nx, arr, axis=-1, descending=False)[source]