This module contains functions for examining couplings after they are fitted, including comparing to a known ground truth. Nothing here is required for applying LineageOT to experimental data.

lineageot.evaluation.coupling_W2(coupling_1, coupling_2, source, target, epsilon)

Returns the entropically-regularized W2 distance between two couplings

lineageot.evaluation.coupling_to_coupling_cost_matrix(source, target)

Returns the (n_source*n_target)*(n_source*n_target) cost matrix for a W2 distance between two couplings of source and target

Source and target here are just expression samples, without barcodes

lineageot.evaluation.expand_coupling(c, true_coupling, distances, matched_dim=0, max_dims_used=inf, xs_used=None)
  • c (ndarray, shape (nx, ny) if matched_dim == 0, (ny, nx) if matched_dim == 1) – Coupling between source x and target y

  • true_coupling (ndarray, shape (nx, nz) if matched_dim == 0, (nz, nx) if matched_dim == 1) – Reference coupling between x and z

  • distances (ndarray, shape (nz, ny)) – Pairwise distances between z and y

  • matched_dim (int) – Dimension in which c and true coupling

  • max_dims_used (int or np.inf) – Set a finite value here to do an approximate calculation based on min(nx, max_dims_used) elements of x

  • xs_used (list or None) – Indices of matched_dim to use in approximate calculation. If None and max_dims_used<nx, indices are randomly selected.


expanded_coupling – Optimal coupling between z and y consistent with the coupling c

Return type

ndarray, shape same as true_couplings

lineageot.evaluation.expand_coupling_independent(c, true_coupling)
lineageot.evaluation.l2_difference(coupling_1, coupling_2)

Returns the pairwise squared distances between rows of the data matrix

lineageot.evaluation.plot2D_samples_mat(xs, xt, G, thr=1e-08, alpha_scale=1, **kwargs)

Plot matrix M in 2D with lines using alpha values

Plot lines between source and target 2D samples with a color proportional to the value of the matrix G between samples.

Copied function from PythonOT and added alpha_scale parameter

  • xs (ndarray, shape (ns,2)) – Source samples positions

  • b (ndarray, shape (nt,2)) – Target samples positions

  • G (ndarray, shape (na,nb)) – OT matrix

  • thr (float, optional) – threshold above which the line is drawn

  • **kwargs (dict) – parameters given to the plot functions (default color is black if nothing given)

lineageot.evaluation.plot_metrics(couplings, cost_func, cost_func_name, epsilons, log=False, points=False, scale=1.0, label_font_size=18, tick_font_size=12)

Plots cost_func evaluated as a function of epsilon

lineageot.evaluation.print_metrics(couplings, cost_func, cost_func_name, log=False)

Prints cost_func evaluated for each coupling in the dictionary couplings

lineageot.evaluation.sample_coordinates_from_coupling(c, row_points, column_points, num_samples=None, return_all=False, thr=1e-06)

Generates [x, y] samples from the coupling c.

If return_all is True, returns [x,y] coordinates of every pair with coupling value >thr

lineageot.evaluation.sample_indices_from_coupling(c, num_samples=None, return_all=False, thr=1e-06)

Generates [row, column] samples from the coupling c

If return_all is True, then returns all indices with coupling values above the threshold

lineageot.evaluation.sample_interpolant(coupling, row_points, column_points, t=0.5, num_samples=None, return_all=False, thr=1e-06)

Samples from the interpolated distribution implied by the coupling

If return_all is True, returns the interpolants between every pair with coupling value >thr. This is the exact interpolant distribution if and only if all nonzero values of the coupling are identical and >thr.

lineageot.evaluation.scaled_l2_difference(coupling_1, coupling_2)
lineageot.evaluation.squeeze_coupling(c, row_cluster_labels=None, column_cluster_labels=None)
lineageot.evaluation.squeeze_coupling_by_late_cluster(c, index)
lineageot.evaluation.tv(coupling1, coupling2)