diffsvg.tl.parallel_curves_test#

diffsvg.tl.parallel_curves_test(beta_1, metric, tau=0.1, cov=None, df_denominator=None)#

Test whether two condition curves are parallel, up to a shape difference tau.

The curves are parallel when they differ only in level, i.e. when their difference d(x) = f1(x) - f0(x) is constant. How far they are from that is shape_diff = sqrt(beta_1 @ metric @ beta_1) (see shape_metric; for a gap that changes linearly it is the slope difference), and the test is H0: shape_diff <= tau against H1: shape_diff > tau.

The statistic is the Wald statistic of the K - 1 shape directions of beta_1 (the constant direction is the level and is left out). With tau = 0 it is the classic test of parallel curves, chi-square with K - 1 degrees of freedom. With tau > 0 it is compared against the largest distribution it can have when the true shape difference is tau: noncentral chi-square with noncentrality tau**2 over the variance of the best-measured shape direction. Shape differences below tau therefore do not become significant however precisely they are measured, while the p-value stays valid for every difference up to tau.

With df_denominator (replicates: the posterior covariance then holds the variation between replicates, which was estimated from only a few) the statistic over its K - 1 degrees of freedom is compared against an F distribution instead (noncentral for tau > 0, with the same noncentrality), which is wider than the chi-square and so keeps the test honest when there are few replicates.

Parameters:
beta_1 numpy.ndarray

Posterior draws of the interaction coefficients, shape (n_draws, K), or their posterior mean, shape (K,) (then cov is required).

metric numpy.ndarray

shape_metric for the basis beta_1 belongs to, shape (K, K).

tau float (default: 0.1)

Smallest shape difference that counts, in units of shape_diff.

cov numpy.ndarray, optional (default: None)

Posterior covariance of beta_1, shape (K, K), when beta_1 is a mean.

df_denominator int, optional (default: None)

Denominator degrees of freedom of the F reference, e.g. the number of replicates minus 2 when comparing two groups of replicates.

Returns:

-shape_diff (float)

Shape difference of the posterior-mean curves. Noise in the fitted curves adds to it, so poorly measured genes show a sizeable shape_diff even when the true curves are parallel; the p-value accounts for that, the raw number does not.

-stat (float)

Wald statistic.

-df (int)

Degrees of freedom, K - 1.

-pval (float)

p-value of H0: shape_diff <= tau.