User guide¶
Moscot is a toolbox which can solve a wide range of tasks in single-cell genomics building upon the concept of Optimal Transport (OT).
Moscot follows three design principles:
moscot applications are scalable. While traditional OT implementations are computationally expensive, moscot implements a wide range of solvers which can handle hundreds of thousands of cells
moscot supports OT applications across multiple modalities
moscot offers a unified user interface and provides flexible implementations
Problems¶
Biological problems¶
Temporal data¶
Problem |
Description |
---|---|
Class for analyzing time-series single cell data based on [Schiebinger et al., 2019]. |
|
Estimator for modelling time series single cell data based on [Lange et al., 2023]. |
Spatial data¶
Problem |
Description |
---|---|
Class for aligning spatial omics data, based on [Zeira et al., 2022]. |
|
Class for mapping single cell omics data onto spatial data, based on [Nitzan et al., 2019]. |
Spatiotemporal data¶
Problem |
Description |
---|---|
Class for analyzing time series spatial single-cell data. |
Multimodal data¶
Problem |
Description |
---|---|
Class for integrating single-cell multi-omics data, based on [Demetci et al., 2022]. |
Generic problems¶
Problem |
Description |
---|---|
Class for solving a linear problem. |
|
Class for solving a Gromov-Wasserstein problem. |
|
Class for solving a fused Gromov-Wasserstein problem. |
Scalability¶
In their original formulation, OT algorithms don’t scale to large datasets due to their high computational complexity. Moscot provides several options to overcome this limitation.
For linear problems we can specify the batch_size
parameter of the solve
method. It determines the number of rows or columns of the cost matrix to materialize during the Sinkhorn iterations. Smaller batch_size
reduces memory complexity, but slightly increases time complexity.
Whenever time complexity in a linear problem (e.g. moscot.problems.time.TemporalProblem
) should be reduced, or memory/time complexity in a quadratic problem should be reduced, we use low-rank OT.
In each solve
method we have the rank
parameter, by default \(-1\) – the full rank.
Whenever possible, it’s best to start with the full rank, but when needed, the rank should be set to a positive integer. The higher the rank, the better the full-rank approximation. Hence, one should start with a reasonable high rank, e.g. \(5000\). Consecutively decrease the rank if needed due to memory constraints. Note that the scale of \(\tau_a\) and \(\tau_b\) changes whenever we are in the low-rank setting. While they should be still between \(0\) and \(1\), empirically they should be set in the range between \(0.1\) and \(0.5\). See Linear problems and Quadratic problems on how to use low-rank solutions.
See below for a more detailed discussion.
Multimodality¶
All moscot problems are in general applicable to any modality, as the solution of the moscot problem only depends on pairwise distances of cells. Yet, it is up to the users to apply the preprocessing. We recommend using embeddings, e.g. scVI-tools based or linear embeddings (PCA for GEX and LSI for ATAC-seq data) of dimension \(10-100\). When working with multiple modalities, we can construct a joint space, e.g. by using VAEs incorporating multiple modalities (MultiVI), or by concatenating linear embeddings (e.g. concatenate PCA and LSI space of GEX and ATAC, respectively)
User interface¶
Moscot problems implement problem-specific downstream methods, so we recommend to use task-specific moscot problems. Yet, we also offer generic solvers with a limited range of downstream applications for more advanced users, which allow for more flexibility.
Hyperparameters¶
The solve
method of moscot problems has a wide range of parameters. In the following, we discuss the most relevant ones:
\(\varepsilon\) - Entropic regularization. This determines the stochasticity of the map. The higher the \(\varepsilon\), the more stochastic the map is.
\(\tau_a\) and \(\tau_b\) - Parameters in \((0, 1]\) that define how unbalanced is the problem on the source and target marginals. The lower the \(\tau\), the more unbalanced the problem. Unbalancedness allows to automatically discard outliers, compensate for undesired distributional shifts, and model cell proliferation and apoptosis. If \(\tau = 1\), the problem is balanced.
\(\alpha\) (only in problems building upon fused Gromov-Wasserstein) - Parameter in \((0, 1]\) that interpolates between the quadratic term and the linear term. \(\alpha = 1\) corresponds to the pure Gromov-Wasserstein problem while \(\alpha \to 0\) corresponds to the pure linear problem.
batch_size
- Number of rows/columns of the cost matrix to materialize during the solver iterations. Larger value will require more memory. See above the Scalability.rank
- Rank of the low-rank OT solver [Scetbon et al., 2021]. If \(-1\), full-rank solver [Peyré et al., 2016] is used. See above the Scalability.
For more hyperparameters and their usage please refer to Linear problems, Linear problems (advanced), Quadratic problems and Quadratic problems (advanced).
Further links¶
For tutorials demonstrating use cases for data analysis please see Tutorials.
For short examples showcasing core moscot functionality please refer to Examples.