Skip to content

ALDEx2 from a behavioural spec; R oracle agrees within MC noise (v0.2.0) - #4

Merged
hyperpolymath merged 8 commits into
mainfrom
feat/aldex2
Oct 2, 2026
Merged

hyperpolymath merged 8 commits into
mainfrom
feat/aldex2

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

ALDEx2 (v0.2.0)

This adds two-group ALDEx2 (aldex2) as native Julia, plus the RCall reference extension and an R oracle. The method is defined by docs/ALDEx2-SPEC.md.

What changed and why

The first native version, built from Fernandes et al. 2013/2014, disagreed with Bioconductor ALDEx2 1.42.0 by more than Monte-Carlo noise. On gut, the Welch p differed by 0.24 against R-vs-R noise of 0.066. On soil, the effect differed by 0.18 against noise of 0.03.

The causes were two definitions the papers leave open:

  1. Expected p and expected BH. These are consistent-sign posterior values. Each direction's one-sided p is doubled and capped at 1, then averaged over instances, and the smaller of the two directions is reported. BH is applied per instance and per direction.
  2. Effect size. The between-group and within-group pairs are drawn independently, with m = min(n1·mc, n2·mc).

Provenance (clean-room)

  • To diagnose the gap, the coding agent read the GPL-3 R source of aldex.ttest, t.fast, wilcox.fast and aldex.effect. No code was copied.
  • The owner then ruled for a separate re-derivation:
    • The spec was committed alone, as 87a6316, before any implementation.
    • A separate agent wrote src/Methods/ALDEx2.jl from the spec. It had no access to the R library, could not deparse R functions, and could not search the web for the source. It confirmed it complied.
    • Its implementation commit is c163e5f.
  • This is also recorded in the spec's Provenance section.

Evidence

  • Pkg.test(): 55/55 pass. This covers P1/P5, P3 (CLR centring) and P6 (feature-relabelling equivariance), each with a planted mutant that the property kills.
  • Oracle at MC 512: 13/13 pass. Log: developer/logs/compositionalda-oracle-20261002d.log.
dataset effect native-vs-R (R-vs-R) Welch p Wilcoxon p
mock 0.099 (0.125) 0.022 (0.028) 0.050 (0.040)
gut 0.032 (0.033) 0.061 (0.066) 0.056 (0.069)
soil 0.030 (0.030) 0.051 (0.043) 0.038 (0.039)

On mock, the q<0.05 call sets are identical: mock1–5 on both sides.

Not proved

ALDEx2's calibration is tested against the reference, not proved. P3 and P6 are property-tested, not Agda-proved. See proofs/PROOF-STATUS.md.

Deliberate departure from the reference

The effect-size index permutations are drawn once and shared across features, where the reference draws them per feature. Each feature's marginal distribution is unchanged. Only the cross-feature correlation differs, and sharing is what makes P6 hold exactly.

Tested with Julia 1.12 (local) and the CI matrix 1.10/1.12, R 4.5.0, Bioconductor 3.22, and ALDEx2 1.42.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1

hyperpolymath and others added 6 commits October 2, 2026 16:04
…tension; oracle harness (WIP: oracle not yet run)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1
…roducible builder, DATASETS.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1
…te Wilcoxon p too

ALDEx2 1.42 calls round() on conds, which errors for a factor; it builds
its own sorted factor, so a character vector gives the same level order.
RCall's rcopy renames R's dotted columns (we.ep -> we_ep).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1
The native and reference results disagreed beyond Monte-Carlo noise. This
documents the two definitions behind that: the consistent-sign expected p
and BH, and independent between/within pairing for the effect. It also
records which reference source was read to diagnose it. Owner ruling: the
code is re-derived from this document by an agent that has not read that
source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1
… from the spec

Re-implemented from docs/ALDEx2-SPEC.md by a separate agent that never had
access to the reference source. Oracle (MC 512) now passes on all three
datasets: native-vs-R is within R's own seed-to-seed noise on effect, Welch
p and Wilcoxon p. Bump to 0.2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2915bd82-7916-4b1d-83cf-386dc9fbc46e

📥 Commits

Reviewing files that changed from the base of the PR and between 76c1970 and 61f7c7b.

⛔ Files ignored due to path filters (4)
  • test/oracle/fixtures/gut_counts.tsv is excluded by !**/*.tsv
  • test/oracle/fixtures/gut_groups.tsv is excluded by !**/*.tsv
  • test/oracle/fixtures/soil_counts.tsv is excluded by !**/*.tsv
  • test/oracle/fixtures/soil_groups.tsv is excluded by !**/*.tsv
📒 Files selected for processing (22)
  • .github/workflows/ci.yml
  • .gitignore
  • Project.toml
  • README.md
  • docs/ALDEx2-SPEC.md
  • docs/DATASETS.md
  • docs/R-SUNSET.md
  • ext/CompositionalDARCallExt.jl
  • src/CompositionalDA.jl
  • src/Methods/ALDEx2.jl
  • test/mutants.jl
  • test/oracle/Project.toml
  • test/oracle/datasets.jl
  • test/oracle/fixtures/gut_counts.tsv.license
  • test/oracle/fixtures/gut_groups.tsv.license
  • test/oracle/fixtures/soil_counts.tsv.license
  • test/oracle/fixtures/soil_groups.tsv.license
  • test/oracle/make_fixtures.jl
  • test/oracle/runoracle.jl
  • test/properties.jl
  • test/property_aldex2.jl
  • test/runtests.jl
 ________________________________________
< I'm a lean, mean, code review machine. >
 ----------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… its error

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1
@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Autopilot could not be updated. Open Coding to check access and billing.

Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
@hyperpolymath
hyperpolymath merged commit 3cf4528 into main Oct 2, 2026
2 of 5 checks passed
@hyperpolymath
hyperpolymath deleted the feat/aldex2 branch October 2, 2026 16:48
hyperpolymath added a commit that referenced this pull request Oct 2, 2026
…re visible (#5)

Main is red after #4 (run 37036456885). This fixes both failures.

- **Agda proofs:** the merge of `main` into `feat/aldex2` kept #3's step
name but put the old Agda 2.7.0.1 download step under it.
`debian:13-slim` has no `curl`, so the job exited with code 127. The
merge also dropped the checkout step. This PR restores #3's job
(`76c1970`) verbatim.
- **R reference oracle:** loading RCall exits with code 1 and prints
nothing. The job now runs one step at a time: R loads ALDEx2, Julia
starts R through RCall (with RCall's build log printed), and the
extension loads. The comparison runs only after those pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_019Y6e175rh1LbrsEhQvCrJ1

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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