API

Alignment

paste.pairwise_align(a_slice, b_slice[, ...])

Returns a mapping \(( \Pi = [\pi_{ij}] )\) between spots in one slice and spots in another slice while preserving gene expression and spatial distances of mapped spots, where \(\pi_{ij}\) describes the probability that a spot i in the first slice is aligned to a spot j in the second slice.

paste.center_align(initial_slice, slices[, ...])

Infers a "center" slice consisting of a low rank expression matrix \(X = WH\) and a collection of \(\pi\) of mappings from the spots of the center slice to the spots of each input slice.

paste.center_ot(feature_matrix, ...[, ...])

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

paste.center_NMF(feature_matrix, slices, ...)

Finds two low-rank matrices ( W ) (feature matrix) and ( H ) (coefficient matrix) that approximate expression matrices of all slices by minimizing the following objective function:

paste.my_fused_gromov_wasserstein(...[, ...])

Computes a transport plan to align two weighted spatial distributions based on expression dissimilarity matrix and spatial distances, using the Gromov-Wasserstein framework.

paste.line_search_partial(alpha, ...)

Solve the linesearch in the fused wasserstein iterations for partially overlapping slices

Visualization

visualization.stack_slices_pairwise(slices, pis)

Align spatial coordinates of sequential pairwise slices.

visualization.stack_slices_center(...)

Align spatial coordinates of a list of slices to a center_slice.

visualization.plot_slice(slice, color[, ax, s])

Plots slice spatial coordinates.

visualization.generalized_procrustes_analysis(...)

Finds and applies optimal rotation between spatial coordinates of two layers (may also do a reflection).

Model Selection

model_selection.generate_graph(slice[, ...])

Generates a graph using the networkx library where each node represents a spot from the given slice object, and edges are formed between each node and its closest neighbors based on spatial distance.

model_selection.convex_hull_edge_inconsistency(...)

Computes the edge inconsistency score for a convex hull formed by the aligned spots

model_selection.select_overlap_fraction(...)

Selects the optimal overlap fraction between two slices, a_slice and b_slice, using a pairwise alignment approach.

Miscellaneous

helper.kl_divergence(a_exp_dissim, b_exp_dissim)

Calculates the Kullback-Leibler divergence (KL) or generalized KL divergence between two distributions.

helper.glmpca_distance(a_exp_dissim, ...[, ...])

Computes the distance between two distributions after reducing dimensionality using GLM-PCA.

helper.pca_distance(a_slice, b_slice, ...)

Computes pairwise distances between two distributions slices after dimensionality reduction using PCA.

helper.high_umi_gene_distance(a_exp_dissim, ...)

Computes the Kullback-Leibler (KL) divergence between two distribution using genes with highest UMI counts.

helper.norm_and_center_coordinates(spatial_dist)

Normalizes and centers spatial coordinates by subtracting the mean and scaling by the minimum pairwise distance

helper.get_common_genes(slices)

Returns common genes from multiple slices

helper.match_spots_using_spatial_heuristic(...)

Matches spatial coordinates between two datasets using either optimal transport or bipartite matching based on spatial proximity.

helper.dissimilarity_metric(which, a_slice, ...)

Computes a dissimilarity matrix between two distribution using a specified metric.