diffsvg.tl.shape_metric#

diffsvg.tl.shape_metric(n_bsplines=10, degree=3, n_grid=2001, support=(0.0, 1.0))#

Quadratic form Q that measures how far two condition curves are from parallel.

For interaction coefficients b (beta_1 of the per-gene model), sqrt(b @ Q @ b) is the shape difference of the difference curve d(x) = f1(x) - f0(x) on [0, 1], in slope-equivalent units: sqrt(12) * RMS(d - mean(d)). When the gap between the curves changes linearly, d(x) = a + s * x, this is exactly |s|, the slope difference; for any other shape it is the linear change with the same RMS departure from parallel. Level differences contribute nothing (Q @ ones = 0). Centring the basis does not change Q, so it depends only on the knots, i.e. on n_bsplines and degree of diffsvg.pp.bin_obs.

Parameters:
n_bsplines default: 10

As in diffsvg.pp.bin_obs.

degree default: 3

As in diffsvg.pp.bin_obs.

n_grid default: 2001

Grid points for the numerical integral.

support default: (0.0, 1.0)

The part of [0, 1] the shape is measured over (see fit_model). Slopes stay in units of the full anchor range.

Returns:

numpy.ndarray Q, shape (n_bsplines, n_bsplines), positive semi-definite with rank n_bsplines - 1.