Skip to content

Add DRAGON cross-language parity test#406

Open
marouenbg wants to merge 2 commits into
netZoo:develfrom
marouenbg:dragon-parity-test
Open

Add DRAGON cross-language parity test#406
marouenbg wants to merge 2 commits into
netZoo:develfrom
marouenbg:dragon-parity-test

Conversation

@marouenbg

Copy link
Copy Markdown
Contributor

Summary

Add a parity test that pins netZooR's dragon() outputs to a fixed numeric snapshot. The same shared inputs and gold values are committed byte-identical in netZooPy (companion PR: netZoo/netZooPy#389). If both tests pass, the two implementations agree to 1e-5 absolute tolerance.

What's covered

  • lambdas (penalty parameters)
  • cov — shrunken covariance
  • prec — precision matrix
  • ggm — partial correlation matrix

What's not covered

  • κ estimation and p-values — currently unimplemented stubs in this package (estimate_kappa_dragon and estimate_p_values_dragon in R/DRAGON.R have empty function bodies; the public dragon() prints "not yet implemented in R; to estimate p-values, use netZooPy"). When R gains a κ/p-value implementation, this parity test should be extended to cover it.

Fixtures

  • Inputs: X1.csv (50×20), X2.csv (50×15) — generated deterministically in netZooPy via tests/dragon_parity/regenerate.py from simulate_dragon_data(seed=20250510), then column-scaled.
  • Gold outputs: lambdas.txt, cov.csv, prec.csv, ggm.csv. Snapshot of netZooPy's pipeline at the time of generation.
  • The same files live byte-identical at netZooPy's tests/dragon_parity/.

Local results

R lambdas : 0.8032896157, 0.8167110796
py lambdas: 0.8032890169, 0.8167107609
cov   max|diff| = 2.20e-7
prec  max|diff| = 2.14e-7
ggm   max|diff| = 1.99e-7

R and Python agree two orders of magnitude tighter than the 1e-5 tolerance.

Companion PR

Test plan

  • Rscript -e 'library(testthat); library(netZooR); setwd("tests/testthat"); test_file("test-dragon-parity.R")' — 4 PASS / 0 FAIL locally
  • CI runs the new test alongside the rest of tests/testthat/test-dragon.R

🤖 Generated with Claude Code

Add a parity test asserting that netZooR's dragon() reproduces a fixed
snapshot of lambdas, shrunken covariance, precision matrix, and partial
correlation matrix. The same shared inputs (X1.csv, X2.csv) and gold
values are byte-identical to netZooPy's tests/dragon_parity/ -- if both
tests pass, the two implementations agree to 1e-5 (atol).

The fixtures are generated by netZooPy's tests/dragon_parity/regenerate.py
from simulate_dragon_data with seed=20250510.

Kappa / p-values are not covered, since estimate_kappa_dragon and
estimate_p_values_dragon are unimplemented stubs in netZooR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The DRAGON parity test runs alongside the rest of testthat, so it
shares the same test-coverage and bioc-check jobs as everything else.
Both have pre-existing problems on devel that this PR was hitting:

- test-coverage was installing the reticulate R package but not Python
  itself, so reticulate::source_python() in pandaPy failed and broke
  the whole testthat run. Mirror bioc-check's Python setup (install
  numpy/scipy/pandas and export RETICULATE_PYTHON), Linux only since
  test-coverage runs on ubuntu-latest.

- bioc-check on R devel couldn't resolve GOstats via pak, taking down
  the dependency install. Use pak directly for the devel matrix entry
  and pass "GOstats=?ignore" so the rest of the deps still resolve.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@marouenbg

marouenbg commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@taraeicher if you accept this, we can rebase and fix #404 for free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant