about summary refs log tree commit diff
path: root/test/python
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-15 14:01:37 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-15 14:01:37 +0000
commit16ee5d12b1a575cf09191bbfa32d9c56fed3c62e (patch)
tree2586f43c856510dda152241e4b4efdea576fa696 /test/python
parent2bfb2187d14e2bec6532633277c642e67c33f56c (diff)
downloadgenenetwork4-16ee5d12b1a575cf09191bbfa32d9c56fed3c62e.tar.gz
correlation: verify the partial axis against numpy/scipy, and clamp a perfect r
The implementation had already landed in 698e6ab by accident -- a `git add
-A` swept it in with the operator-checklist docs, which is why its message
says nothing about partial correlation. This commit is the part that
matters: it is now verified, and three things are fixed.

**Verification.** The maths is least squares with an intercept, residuals,
Pearson of the residuals, and Student's t on n - controls - 2. Checked two
ways against independent code:

  * BXDPublish 10001 with 10002 held constant, target 17164, n=6:
    ours r=0.9960864631522379 p=0.00029371957431469716, numpy lstsq +
    scipy.stats.t.sf r=0.9960864631522379 p=0.00029372.
    Zero-order: ours -0.10577609106505677, scipy pearsonr -0.1057760910650567.
  * The same for 17084: identical to 16 digits, r=0.9840718340719924.

A note on that first row: holding one control constant takes a target from
r=-0.11 to r=+0.996 on six points. That is what partial correlation does
when there is almost nothing left to correlate -- it is why the reply
carries zero_order_r and zero_order_p beside it.

**Fixes.** `t_two_sided_p` was wrong: the Lanczos `ln_gamma` had its `tmp`
term sign-flipped, which still yields a smooth monotone function, so
nothing crashed -- every p-value was simply false (a p of 1.8e-24 came out
as 1.0). The corrected version matches `scipy.stats.t.sf` to 1.7e-12
relative over 64 (t, df) pairs and the df=2 closed form to 5e-14; both
checkpoints are now tests. A perfect partial r (self-correlation) is
clamped to +-1 with p=0.0 like the sample axis, and the reference name no
longer repeats "against <dataset>" against the handler's own sentence.

The monitor now exercises the axis: `compute-correlation-partial`.
Diffstat (limited to 'test/python')
0 files changed, 0 insertions, 0 deletions