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 isshape_diff = sqrt(beta_1 @ metric @ beta_1)(seeshape_metric; for a gap that changes linearly it is the slope difference), and the test isH0: shape_diff <= tauagainstH1: shape_diff > tau.The statistic is the Wald statistic of the
K - 1shape directions ofbeta_1(the constant direction is the level and is left out). Withtau = 0it is the classic test of parallel curves, chi-square withK - 1degrees of freedom. Withtau > 0it is compared against the largest distribution it can have when the true shape difference istau: noncentral chi-square with noncentralitytau**2over the variance of the best-measured shape direction. Shape differences belowtautherefore do not become significant however precisely they are measured, while the p-value stays valid for every difference up totau.With
df_denominator(replicates: the posterior covariance then holds the variation between replicates, which was estimated from only a few) the statistic over itsK - 1degrees of freedom is compared against an F distribution instead (noncentral fortau > 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,)(thencovis required).- metric numpy.ndarray
shape_metricfor the basisbeta_1belongs 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), whenbeta_1is 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_diffeven 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.
- -shape_diff (