Repository navigation
MC-2: default the controls to the experiment description of a MorphoFeature export - #630
Merged
Merged
Conversation
The exports of v03, v27, v30 and v33 come from MorphoFeature main d33c628 (after #215, MF-5b, and #216), with its pinned core (preprocessing v0.5.1, CellPatcher v0.4.0, normalization v0.4.0). Only coverage.json changes in each export: schema_version 2 -> 3 and the experiment block as its last key; fovs.csv, objects.csv, applicability.csv and tables/shape.csv are byte-identical. provenance.json records the new commit and versions. make_exports.py follows MorphoFeature main's run file: the channels are the description's (no `channels`, no `shared_channel_layout`), and the mask is named by its ID, `Cells`. Two runs give byte-identical files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
… export (MC-2) morphocoverage.described reads the experiment block of MorphoFeature's coverage.json (MF-5b, schema_version 3; MorphoFeature design note coverage-experiment-block-2026-11-12, sections 2 and 4) beside the FOV table: - read_experiment(coverage, fovs) checks every export of the analysis and gives the description's default controls: one control when every other condition references it, else one own_control row per condition and its reference, so a chain (v10) is compared as a chain. A condition whose control has no field, or that shares no repeat with it (W_REFERENCE_UNPAIRED), is not compared, and said. - workflows.described_setup(experiment, ...) and scan_design(..., description=experiment) use that default; a control the user declares overrides it, and the declaration (printed first by the report) names the description's reference beside the user's choice. - Setup(targets=...) takes the reagent grouping the user confirmed (TargetSuggestions.confirm()), a copy; the description's suggestions themselves are refused until confirmed. Refused (DescriptionRefused.code): unknown coverage.json or description versions, an unexported set, a malformed block, a block that disagrees with the FOV table (also when a workflow reads another FOV table), exports of two descriptions, unconfirmed suggestions. A described FOV table whose export has no block defaults no control and guesses none from the names; controls declared by ID are accepted (owner decision, 12 Nov 2026). Analyses that do not pass a description are unchanged: the report, its HTML page, the contrast table and the scan of v03, v27, v30 and v33 are byte-identical to main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
described.py, _described_shape.py, workflows/_described.py and workflows/_scan_names.py join the package map (test_agents_section_7_lists_every_module). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
…rols (MC-2 review)
The notes of a described export ("DrugA: not compared: the description declares no
reference for it", "its control CTRL has no field", W_REFERENCE_UNPAIRED) say what the
description's references alone compare. When the user declares other controls, the report
may compare those very conditions (DrugA vs CTRL), yet the declaration still printed
"DrugA: not compared", which is false of the report. Under an override each note now reads
"By the description's references alone, ..."; without one they are unchanged.
Regression test: test_an_override_never_says_a_compared_condition_is_not_compared.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc
Contributor
Author
Independent review of MC-2: merge, with one fix (df09a99)I checked this PR against the design note (MorphoFeature Fix (its own commit,
|
This was referenced Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 2 step MC-2: MorphoCoverage reads the
experimentblock that MorphoFeature's MF-5b (CellMigrationLab/MorphoFeature#215, mergedaafeaff) writes into each exportedcoverage.json(schema_version3). The controls now default to the description's references. Thetargetsuggestions are used only after the user confirms them. Every refusal in §4 of the design note is applied.Sources: MorphoFeature design note
docs/restart/designs/coverage-experiment-block-2026-11-12.md(branchclaude/restart-doc,1b429d7), §2, §4 and §5. Stage 2 planstage2-plan-2026-11-09.md, rows MC-0, MC-1 and MC-2.What MC-2 does
New public module
morphocoverage.described, with its shape checks in the private_described_shape.py:read_experiment(coverage, fovs)reads thecoverage.jsonof every export in one analysis (a path, an export folder, aCoverageRecord, or a list of them) beside the FOV table. It returns aDescribedExperiment.Default controls = the
referencesgraph (plan MC-2, owner answer 1). There are two shapes:{"condition": X}. Forv03,v27,v30andv33this gives exactly what a user would get by declaring that control, and the test asserts the contrast tables are equal.own_controlrow per (condition, reference). A chain is therefore compared as a chain (v10:VEC_SiCol6a1 vs VEC_SiNC,VEC_SiNC vs VEC, and the same for THBS5). No condition is compared with a root it does not reference.The default is not an error in these cases (note §4, "Not a refusal"), and each is stated in the declaration:
W_REFERENCE_UNPAIRED;None of these conditions is ever compared with another control.
workflows.described_setup(experiment, **Setup fields)applies the default.scan_design(..., description=experiment)passes it toDesignScan.setup().control,contrasts,control_parentsormaster_control) overrides the default.Setup.describedrecords the override, and the declaration, which the report prints first, says: "Controls: chosen by the user, overriding the experiment description (description bd5099bfe78b): the description gives DrugA vs CTRL; the user chose DrugB."Suggestions.
experiment.target_suggestionsis deliberately not a mapping.Setup(targets=suggestions)is refused withsuggestion_not_confirmed.suggestions.confirm(), orconfirm({"DrugB": "SRC"})with edits, returns a plain copy. That copy is the only grouping the condition contrast reads, as the working FOV table'stargetcolumn.v27,SRCandsrcare two targets.The scan, given a description:
Refusals (
DescriptionRefused.code), note §4coverage_version_unknown(schema_version above 3, below 1, not an integer, or a bool),description_version_unknown(checked before the shape),coverage_set_not_exportedtest_an_unknown_*,test_an_unexported_set_is_refusedexperiment_block_missing: a described FOV table (condition_id) whose export is v2 or has no block. Only the default is refused. Controls declared by ID are accepted and stated, and the scan guesses no control and no reagents from the names (owner decision, 12 Nov). An export with the block beside one without it also defaults nothing.test_without_the_block_*,test_one_export_without_the_block_*experiment_block_malformed: 21 mutations (missing or extra key at each level; SHA-256 or digest not 64 lower-case hex; wrong types; a reference or member that is not a condition, including a case variantctrl/CTRL; a condition missing fromreferencesorsuggestions; a self-reference), a block in a v2 record, and invalid JSONtest_a_malformed_block_is_refused[*]experiment_block_disagrees_with_fovs:condition≠source_folderof its ID; unknowncondition_id; unknownrepeat_group;biological_repeat≠source_repeat; a block beside a FOV table without IDs. The check runs again in every workflow (paired_inputs), so a report given another FOV table is refused.test_a_block_that_disagrees_*,test_a_workflow_reading_another_fov_table_*experiment_descriptions_differ(owner decision, 12 Nov)test_exports_of_two_descriptions_are_refusedsuggestion_not_confirmedtest_v27_unconfirmed_suggestions_*condition_named_by_folder_label, also for an override and for target keystest_the_override_by_folder_label_*,test_confirmed_targets_name_conditions_by_idtests/test_described.pyhas 67 tests. They all fail on main: the module does not exist there, so collection fails.Plan acceptance tests (MC-2 row)
v27: an unconfirmed prefill is refused for analysis, the confirmed grouping is used, and editingtargetchanges no confirmed grouping. Three tests.v10is compared as a chain:test_v10_the_chain_is_compared_as_a_chain. There is no golden export forv10, so the test builds the tables and the block from the vendored TOML, following note §2.3.Golden exports (re-made from MorphoFeature main)
The exports were re-made with
make_exports.pyfrom MorphoFeature maind33c6284e4a860eff08cbdfcc098c8069e963234(after CellMigrationLab/MorphoFeature#215 and CellMigrationLab/MorphoFeature#216), in a fresh venv with its pinned core: preprocessing 0.5.1, CellPatcher 0.4.0, normalization 0.4.0, numpy 2.5.4, pandas 3.1.1, Python 3.13.18. Two runs gave byte-identical files.Only
coverage.jsonchanges in each export.fovs.csv,objects.csv,applicability.csvandtables/shape.csvare byte-identical.provenance.jsonrecords the new commit and package versions.In each
coverage.json,"schema_version": 2becomes3, and"experiment": {...}is added as the last key. Thev03andv33description_sha256values equal the note's §5 "with the Cells mask" values (bd5099bf…,20aded4a…). A test asserts this.make_exports.pyhad to follow MorphoFeature main's run file. It now names nochannelsorshared_channel_layout, because MF-2 takes the channels from the description and refuses the sortedused_idsorder. It also names the mask by its ID,Cells, because MF-3 refusescells: present in 0 of 33. The README records this.Before/after: analyses without the block are byte-identical
I wrote a script that runs, on each of
v03,v27,v30andv33:scan_design(full summary andrepr(design));reportwith the declared control (full summary and declaration);html_report(page and every figure file).I ran it on a
mainworktree (ba44bf7) and on this branch, withSOURCE_DATE_EPOCH=0for the PDFs and the page's "Generated " masked. Result: 44 files, 44 identical SHA-256 (diffempty). Two runs on main also matched each other.Gate
Run on head
a4cf9a4(Python 3.13.18, in a venv that also holds MorphoFeature main and its core):pytest -n 0 tests/test_guards.py tests/test_function_guards.py tests/test_function_tools.py: 102 passed.python tools/audit.py --check-against origin/main: baselines only tightened against origin/main.python -m ruff check src tests data: all checks passed.python -m ruff format --check src tests data: 532 files already formatted.pytest -n 4): 4616 passed, 2 skipped, 6 xfailed, 0 failed (11 min).tests/test_morphobricks_constants.py:31: "morphobricks-preprocessing 0.5.1 is installed; the check needs 0.3.4". This is the venv's MorphoFeature core, not this change.553cbdd, had 1 failure,test_contracts.py::test_agents_section_7_lists_every_module. AGENTS.md §7 did not list the new modules, anda4cf9a4fixes it.a4cf9a4:checksuccess,spec-pinsuccess.Owner questions (recommendation first)
coverage.json, still get the scan's name-based control suggestion ("ctrl (named like a control; not declared)"), as on main. The note's §1 says a name guess is what §3.4 forbids once a description exists. Recommend: a small follow-up that suppressescontrol_guessandreagent_groupswhenever the FOV table hascondition_id. That changes the scan text of the four fixtures, so I left it out to keep this PR's before/after byte-identical.scan.setup()already refuses a guessed control on main, so no analysis uses the guess.guide()) does not take a description yet. Recommend: a follow-up that givesguide()thecoverage.json, so it skips the control question when a default exists and asks the user to confirm the target suggestions.experiment_block_missing) and declared controls are accepted, the same as refusal 2.morphocoverage.described,morphocoverage.workflows.described_setup(added toworkflows.__all__), and theSetupfieldsdescribedandtargets. The top-levelmorphocoverage.__all__is unchanged. Recommend: accept them as MC-2's interface.v10golden. Recommend: addv10tomake_exports.pyat the next golden refresh, so the chain test reads a real MorphoFeature export instead of a block built from the TOML.Related: filed CellMigrationLab/MorphoFeature#217 (patch-only runs record only
cellpatcher_version; addcore, as CellMigrationLab/MorphoFeature#216 did).🤖 Generated with Claude Code
https://claude.ai/code/session_01G3qp9AxjpGPw9xfWAUJNqc