moscot.backends.ott.output.OTTNeuralOutput.project_to_transport_matrix¶
- OTTNeuralOutput.project_to_transport_matrix(src_cells, tgt_cells, forward=True, condition=None, save_transport_matrix=False, batch_size=1024, k=30, length_scale=None, seed=42, recall_target=0.95, aggregate_to_topk=True)[source]¶
Project conditional neural OT map onto cells.
In constrast to discrete OT, (conditional) neural OT does not necessarily map cells onto cells, but a cell can also be mapped to a location between two cells. This function computes a pseudo-transport matrix considering the neighborhood of where a cell is mapped to. Therefore, a neighborhood graph of k target cells is computed around each transported cell of the source distribution. The assignment likelihood of each mapped cell to the target cells is then computed with a Gaussian kernel with parameter length_scale.
- Parameters:
condition (
Optional
[ndarray
[Any
,dtype
[float64
]]]) – Condition src_cells correspond to.src_cells (
ndarray
[Any
,dtype
[float64
]]) – Cells which are to be mapped.tgt_cells (
ndarray
[Any
,dtype
[float64
]]) – Cells from which the neighborhood graph around the mapped src_cells are computed.forward (
bool
) – Whether to map cells based on the forward transport map or backward transport map.save_transport_matrix (
bool
) – Whether to save the transport matrix.batch_size (
int
) – Number of data points in the source distribution the neighborhoodgraph is computed for in parallel.k (
int
) – Number of neighbors to construct the k-nearest neighbor graph of a mapped cell.length_scale (
Optional
[float
]) – Length scale of the Gaussian kernel used to compute the assignment likelihood. If None, length_scale is set to the empirical standard deviation of batch_size pairs of data points of the mapped source and target distribution.seed (
int
) – Random seed for sampling the pairs of distributions for computing the variance in case length_scale is None.recall_target (
float
) – Recall target for the approximation.aggregate_to_topk (
bool
) – When true, the nearest neighbor aggregates approximate results to the top-k in sorted order. When false, returns the approximate results unsorted. In this case, the number of the approximate results is implementation defined and is greater or equal to the specified k.
- Return type:
- Returns:
: The projected transport matrix.