Skip to content

feat(eval): turn cafaeval's per-protein vectors into a joinable table - #784

Merged
github-actions[bot] merged 1 commit into
developfrom
feat/persist-per-protein-scores
Aug 19, 2026
Merged

github-actions[bot] merged 1 commit into
developfrom
feat/persist-per-protein-scores

Conversation

@frapercan

Copy link
Copy Markdown
Owner

The layer that makes stratification possible, plus the cafaeval pin that feeds it
(frapercan/cafaeval-protea#25).

Why the board can only stratify by two axes today

Three of the axes this project is required to report are properties of a
protein: sequence length, identity to the nearest donor, taxonomic relation
to it. The stored evaluation is one number per (category, aspect) cell, so none
of them is recoverable from it however it is sliced. Category and aspect are
reportable only because cafaeval happens to partition the ground truth on them
before aggregating.

PerProteinSink hands over the vectors before .sum(axis=0) collapses them.
This module turns one sink into rows keyed by accession, which join to
protein.length and to identity_nw / taxonomic_relation in go_prediction.

Three ways to be quietly wrong, each refused

Wrong threshold column. cafaeval builds thresholds as
arange(th_step, 1, th_step). We rebuild that and assert the width matches the
emitted arrays rather than trusting the reconstruction; an off-by-one would score
every protein at a neighbouring threshold, which reads as a plausible number. The
assertion earned itself immediately by catching a wrong fixture in its own test.

Wrong protein. Two numberings are in play: the NK/LK kernel sees every row,
the PK kernel is handed pred[proteins_has_gt]. A record lacking either the id
map or the row index, or whose row index length disagrees with the arrays, is
dropped rather than written under a guess. This is the positional
misalignment that cost this project a fortnight in its neighbour search.

NaN. A protein that predicted nothing, or that has no ground truth, scores
zero rather than NaN, because a NaN propagates into every stratum mean that
contains it and turns one empty cell into a blank row.

Two deliberate narrowings

Only the weighted variant is kept. f_micro_w is what every published cell
here reports, and an unweighted row would be a different metric under the same
column name.

A parquet artifact, not a table. A table would need a migration, and
migrations here are validated offline and never applied as a side effect of
running an evaluation.

Checks

Eleven tests, one per failure mode above plus the arithmetic and a check that the
per-protein rows sum to the totals the aggregate is built from. ruff clean,
smell budget unchanged.

Three of the axes this project must report, sequence length, identity to
the nearest donor and taxonomic relation to it, are properties of a
PROTEIN. The stored evaluation is one number per (category, aspect) cell,
so none of them can be recovered from it however it is sliced. That is
why the board can only stratify by the two axes cafaeval happens to
partition on.

Adds the layer that reads a PerProteinSink and produces rows keyed by
accession, so they join to protein.length and to the donor identities in
go_prediction. The cafaeval pin moves to the build that can fill a sink.

Three ways this could quietly produce a wrong table, each refused rather
than guessed:

Reading the wrong threshold column. cafaeval builds its thresholds as
arange(th_step, 1, th_step); we rebuild that and assert the width matches
the emitted arrays. An off-by-one would score every protein at a
neighbouring threshold, which reads as a plausible number. The assertion
already earned itself by catching a wrong fixture in its own test.

Naming rows by the wrong protein. Two numberings are in play and the PK
kernel is handed a subset, so a record without both the id map and the
row index is dropped rather than written under a guess. This is the
positional misalignment that cost a fortnight in the neighbour search.

Emitting NaN. A protein that predicted nothing, or that has no ground
truth, scores zero, because a NaN propagates into every stratum mean that
contains it.

Only the weighted variant is kept: f_micro_w is what every published cell
here reports, and an unweighted row would be a different metric under the
same column name.

Parquet artifact rather than a table, so no migration is applied as a
side effect of running an evaluation.
@github-actions
github-actions Bot enabled auto-merge (squash) August 19, 2026 08:38
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.66%. Comparing base (2e4d5bb) to head (84ec7dc).
⚠️ Report is 51 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #784      +/-   ##
===========================================
- Coverage    89.02%   87.66%   -1.36%     
===========================================
  Files          246      264      +18     
  Lines        18669    20470    +1801     
===========================================
+ Hits         16620    17945    +1325     
- Misses        2049     2525     +476     
Files with missing lines Coverage Δ
protea/core/operations/_run_cafa_per_protein.py 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
github-actions Bot merged commit 853a31e into develop Aug 19, 2026
21 checks passed
github-actions Bot pushed a commit that referenced this pull request Aug 19, 2026
…le (#785)

#784 landed the transformation layer with its tests and nothing called
it. This
is the wiring: a sink per cafaeval invocation, and the table written
beside the
setting's other artefacts.

## Two decisions

**Collected always**, not behind a flag. The cost is one array per
namespace held
for the length of the call. A flag would be off exactly when someone
wants to
stratify a result that has already been computed.

**Never fatal.** The aggregate is the product; a supplementary table
that cannot
be written must not discard a sound evaluation. Both the empty and the
failed
case emit an event, so an absent file is distinguishable from one nobody
asked
for.

## Two defects found while wiring, neither in the new code

**The namespace keys disagreed.** `parse_results` returns the short CAFA
code
(`BPO`) and the sink reports cafaeval's long namespace
(`biological_process`). A mismatch produces an empty tau map, no rows,
and no
file, with nothing anywhere saying why. Fixed by inverting the project's
own
`_NS_LABELS` rather than writing a second mapping that could drift from
it, with
a test asserting the two still line up.

**The sink import sat inside a broad `except Exception`.** An installed
cafaeval
without `PerProteinSink` was swallowed and reported as three settings
that
produced no results, so a wrong dependency version looked exactly like
an
evaluation that legitimately scored nothing. I hit this on my own
machine: 91
driver tests failed with `cafa_eval.call_count == 0` and a green-looking
run
underneath. The import now sits in a helper that raises with a message
naming
the real problem.

That second one is the reason I am flagging it here rather than fixing
it
quietly: I introduced it in this branch by adding an import to a
protected
block, which is the same failure family this work exists to remove.

## Checks

91 driver tests, 5 wiring tests, 11 transformation tests, all passing
with the
new dependency installed. `ruff` clean, smell budget unchanged.
@frapercan
frapercan deleted the feat/persist-per-protein-scores branch September 15, 2026 18:28
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