Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ MorphoCoverage does not replace the user's final biological inference workflow,
- **the lab's Plot&Stats cell-level test**: Cohen's d and a randomization test over the observations pooled as provided, on raw values and on values divided by the mean of the same repeat's control, labelled with its chance of p <= 0.05 without an effect, `2·P(Z > 1.96/√(1 + n·s²/2))` (`n` the observations per well, each repeat weighted by its share; `s` the SD between repeats), checked against `data/simulations/test_choice.py` and `unbalanced.py` (`contrast_cells`). When the repeats are unbalanced (one holds more than 25% more observations than another on a side, or the control is pooled from repeats the condition was not imaged in) it is also given balanced: against the control of the condition's own repeats, one permutation test whose d is the median over 100 draws of the same number of observations from every repeat and whose p shuffles the condition and control labels within each repeat, the same statistic on the same draws for each shuffle, `(extreme + 1) / (B + 1)` (owner, 2026-10-05; before, the median p over the draws, which is not the p of one test). A repeat under a quarter of the median repeat (or with fewer than 5 observations) is named and left out of the balanced test only;
- **within each repeat**, Cohen's d and the JCS effect size on objects, field means and technical-repeat means, with a randomization test over whole technical repeats only when its smallest p can reach 0.05 after Bonferroni (4 a side for one contrast), over whole fields only without a technical-repeat column;
- with a `target` column, whether independent reagents for one target are on the same side of the control in every repeat (described, not tested);
- **one reading per condition** that puts these together (`reading_text`): significant across repeats (the paired test, normalised, q <= 0.05 after Benjamini-Hochberg within the sub-experiment: the conditions sharing their repeats and control, `_experiments`, owner 2026-10-01), same direction in every repeat but not significant (from 6 repeats, `TREND_REPEATS`; with fewer it happens by chance too often, exactly `2^(1-n)`: 25% with 3, 12.5% with 4, 3.1% with 6, so the verdict is not significant across repeats, or not tested with 2; owner, 2026-10-06, audit 8), no consistent direction, or one repeat; then the evidence (with exactly 3 repeats, each repeat's change and the 95% t interval of the change, and "very limited biological replication" said once per section; plan v2, owner 2026-10-06), and when the raw pooled test disagrees, what it does differently;
- **one reading per condition** that puts these together (`reading_text`): significant across repeats (the paired test, normalised, q <= 0.05 after Benjamini-Hochberg within the sub-experiment: the conditions sharing their repeats and control, `_experiments`, owner 2026-10-01), same direction in every repeat but not significant (from 6 repeats, `TREND_REPEATS`; with fewer it happens by chance too often, exactly `2^(1-n)`: 25% with 3, 12.5% with 4, 3.1% with 6, so the verdict is not significant across repeats, or not tested with 2; owner, 2026-10-06, audit 8), not assessed across repeats when 3 or more repeats give the same change, so the paired test has no variance to test with (never read as not significant, #90), no consistent direction, or one repeat; then the evidence (with exactly 3 repeats, each repeat's change and the 95% t interval of the change, and "very limited biological replication" said once per section; plan v2, owner 2026-10-06), and when the raw pooled test disagrees, what it does differently;
- planning the next experiment at the design the user ran (`repeat_plan`; see "Pilots get advice", section 3);
- **with several features, which of them separate the conditions** (`discovery`, owner decision of 2026-10-01): every feature and condition by the cell-level test in the version the readings trust most (normalised, balanced when unbalanced), Benjamini-Hochberg over all of them within each sub-experiment as the discovery gate, ranked by |d|; the paired t on the repeat means, corrected the same way, beside it as the second gate ("significant across repeats"), and the direction in each repeat. The plots draw the best-ranked (`plots(..., ranking=report.discovery)`), and `embedding_plots` the PCA (the best-ranked as arrows) and UMAP of all the features. The ranking over whole technical repeats (`ranking`) is shown only when there are wells to shuffle.

Expand Down Expand Up @@ -174,7 +174,7 @@ Where practical, preserve compatibility with MorphoBricks metadata names such as
| `condition` | string, always | Default analysis group; always part of FOV identity. |
| `biological_repeat` | string, always (`YYYY_MM_DD`, or `single`) | Default analysis group; always part of FOV identity. Any label is accepted; the format is not enforced. Formerly `repeat`, which is refused (below). |
| `repeat_group` | string, beside `biological_repeat` (MorphoBricks-Spec experiment-v1 section 3.4) | The canonical repeat ID: the biological repeat a folder belongs to. **Every pairing of repeats reads it, never `biological_repeat`** (#617; `_repeat_groups.paired_tables`): the paired analyses and the workflows replace each folder label by its repeat group in working copies (unchanged when every label is its group), so `CTRL/rep1` and `DrugA/experiment_23` of one group pair, and `rep1` of two conditions may be two repeats. Absent beside `biological_repeat`, or ambiguous (a folder in two groups, a group with two folders of one condition, an empty value, an observation table that disagrees): the paired analysis raises `PairingRefused` with its `code`; `report` and the figures run what needs no pairing and say why, `optimise` and `benchmark` refuse. No fallback to the folder label. The analyses that pair take `repeat_col="repeat_group"` by default; `repeat_col="biological_repeat"` named explicitly pairs by folder name and is refused while the tables hold `repeat_group` (MC-1). MorphoFeature's coverage export writes it in `coverage/<object_set>/fovs` (MF-5). Never a feature. |
| `condition_id` | string, beside `condition` (experiment-v1 section 3.4) | The canonical condition ID. With it, the paired analyses and the workflows name every condition by its ID in working copies (`_repeat_groups`), so a control is declared by its ID; a folder label that is not an ID is refused, naming the ID (`condition_named_by_folder_label`), in a control, a positive control, a Setup's `experiment` mapping, comparisons and a contrast table alike; a positive control or an `experiment` key that matches no condition is refused, listing the condition IDs (`condition_not_found`, #628). The source label is never replaced in what the user reads: the condition contrast's per-repeat rows gain `folder` and `control_folder`, the fields to check name their folders and the report and its page say which folder is named by which ID (`settings["repeat_pairing"]`). One ID per folder and one folder per ID, else `PairingRefused`. The analyses that do not pair read conditions by their IDs too, the repeats as given (`_repeat_groups.named_by_id`, #628): `check_tables` (a folder label is a problem naming the ID), `scan_design` (its conditions, control guess and `Setup` use the IDs; its tables keep the folder labels), `dataset_overview`, `plots_of_data`, `pairwise_contrasts` and `fov_clustering`. Never a feature. |
| `condition_id` | string, beside `condition` (experiment-v1 section 3.4) | The canonical condition ID. With it, the paired analyses and the workflows name every condition by its ID in working copies (`_repeat_groups`), so a control is declared by its ID; a folder label that is not an ID is refused, naming the ID (`condition_named_by_folder_label`), in a control, a positive control, a Setup's `experiment` mapping, comparisons and a contrast table alike; a positive control or an `experiment` key that matches no condition is refused, listing the condition IDs (`condition_not_found`, #628). The source label is never replaced in what the user reads: the condition contrast's per-repeat rows gain `folder` and `control_folder`, the fields to check and the acquisition anomalies' rows name their folders (`folder`, #628) and the report and its page say which folder is named by which ID (`settings["repeat_pairing"]`). One ID per folder and one folder per ID, else `PairingRefused`. The analyses that do not pair read conditions by their IDs too, the repeats as given (`_repeat_groups.named_by_id`, #628): `check_tables` (a folder label is a problem naming the ID), `scan_design` (its conditions, control guess and `Setup` use the IDs; its tables keep the folder labels), `dataset_overview`, `plots_of_data`, `pairwise_contrasts` and `fov_clustering`. Never a feature. |
| `technical_repeat_id` | string, beside `technical_repeat` | The canonical technical-repeat ID: metadata, never a feature, not used for grouping. |
| `technical_repeat` | string, optional | The technical repeat within a biological repeat (a well, a dish, a coverslip); never a biological repeat. When present: a default analysis group and part of FOV identity, counted in the report's overview, the shape of the plots' points and the unit their intervals and the condition contrast and feature ranking resample or shuffle first (the contrast and the ranking take the FOV table's column whatever `group_cols` says), and the sample level of the hierarchy `Setup` derives for "more fields or more technical repeats?". Identified with its `condition` and `biological_repeat`, so well `J23` of two plates is two technical repeats. |
| `image_file` | string, always | Storage provenance; fallback FOV identifier only when one file = one spatial position. |
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ inventory's, not the Stage 2 MC-1/MC-2 of the experiment description.

### Fixed

- **#90 (part).** A paired test across repeats that gives no p because 3 or more repeats all
give the same change is now "not assessed across repeats" (`reading_text.NOT_ASSESSED`),
never "not significant": in the reading, the summary, and the page's table across repeats,
where the verdict gives the reason (`contrast_repeats.NO_SPREAD`). Panel C of the figures
marks such a pair "=" with its reason, apart from "–" (fewer than 3 repeats imaged both),
in the static figure, its legend and the interactive hover, which said "fewer than 3" for
both. "Plan the next experiment" keeps a condition whose repeat plan has no estimable
answer, as "not assessable" with the plan's status, instead of leaving it out (and then
saying every condition was significant). The shared machine-readable status vocabulary of
#90 is not part of this change.
- **#557.** The PCA figure's loading labels are placed beside their own arrows. Labels were
moved apart from the lowest up and returned in that order, while the names followed the
loadings' order, so a feature's name could sit at another feature's arrow; the positions
now come back in the loadings' order (`plots_embedding._spread_labels`).
- **#555.** `percent` (and `percent_fine`) no longer raises a math domain error for a share
just below 100% (1 - 1e-12, or the float just below 1): the gap to 100% was rounded to 0
before its log was taken. The gap is now kept to the digits a float holds of it, so such a
share reads `99.9999999999%`, never `100%`; ordinary shares read as before.
- **#628 (item 3).** On exports that name conditions by `condition_id` or pair repeats by
`repeat_group`, the acquisition anomalies' rows now name their folders, as the comparison
rows and the fields to check do: a `folder` column and the folders in the row's field
(`ctrl · repeat rep1 · img0 (folder control/rep1)`), in the report and on its page
(`_pairing.with_folder_labels`). A table whose folders are their IDs is unchanged.
- **#642.** `html_report`, `plots` and `plots_of_data` with `group_cols=("condition",
"repeat_group")`, the groups of MorphoFeature's notebooks, no longer raise "group_cols ...
hold ['repeat_group'], which the figure does not place". The figures place `repeat_group`
Expand Down
2 changes: 1 addition & 1 deletion docs/common/data_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ result.
| `condition` | both, or FOV table only | string | Experimental group. A default analysis group and part of field identity. Needed to declare a control (`Setup.control`), to normalise to it, and for the condition contrast. |
| `biological_repeat` | both, or FOV table only | string | Biological repeat, `YYYY_MM_DD` or `single` in MorphoBricks; any label is accepted. A default analysis group and part of field identity. Normalisation and the condition contrast work within each repeat. Formerly named `repeat`: that name is refused (see [The former name `repeat`](#the-former-name-repeat)). |
| `repeat_group` | FOV table (may also be in the observation table) | string | The confirmed biological repeat a folder belongs to: the canonical repeat ID of the MorphoBricks experiment description (MorphoBricks-Spec experiment-v1 section 3.4), written beside the folder label `biological_repeat`, which stays the field's identity. **Repeats are paired by it, never by `biological_repeat`** (#617): the condition contrast, the feature ranking and discovery, the normalisation to the control of the same repeat, the object rule, unusual observations within their sub-experiment and a positive control paired within repeats all read it, so `CTRL/rep1` and `DrugA/experiment_23` in one repeat group are one biological repeat, and `rep1` of two conditions may be two. Required whenever the FOV table has a `biological_repeat` column and an analysis pairs repeats: without it, or when it is ambiguous (a folder in two groups, a group holding two folders of one condition, a field without a value, an observation table that disagrees), the paired analysis is refused with the reason (`PairingRefused`, its `code`); `report` then runs what needs no pairing and says, under question 9, why nothing was compared. Nothing falls back to the folder label. In a table of your own whose folder labels are the repeats, set it to `biological_repeat`; a table with labels equal to their groups gives the same results as before. The analyses that pair repeats take `repeat_col="repeat_group"` by default; `repeat_col="biological_repeat"` named explicitly pairs by folder name and is refused while the tables hold `repeat_group` (`PairingRefused`, code `repeat_col_pairs_by_folder_label`). A column of your own named with `repeat_col` (or `repeat_col=None`, the whole table one repeat) is your explicit declaration and is used as given. Never a feature. |
| `condition_id` | FOV table (may also be in the observation table) | string | The condition's ID in the MorphoBricks experiment description, beside the folder label `condition`, which stays the field's identity (experiment-v1 section 3.4; `v33`: the folder `control` has the ID `ctrl`). With it, the paired analyses and the workflows name every condition by its ID, so a control is declared by its ID (`Setup(control={"condition": "ctrl"})`); a control named by a folder label that is not an ID is refused with the ID to use (code `condition_named_by_folder_label`), as is a positive control, a Setup `experiment` mapping, comparisons or a contrast table that names one; a positive control or an `experiment` key that matches no condition is refused, listing the IDs (code `condition_not_found`). `check_tables`, `scan_design`, the overview and the plots read conditions by their IDs too. The outputs keep the folder label beside the ID: the per-repeat rows of the condition contrast gain `folder` and `control_folder` (`DrugA/experiment_23`), the fields to check name their folders, and the report and its page say once which folders are named by which ID. Each folder must have one ID in every field and each ID one folder (else `PairingRefused`: `condition_id_empty`, `condition_id_split`, `condition_id_merged`, `condition_id_disagrees`, `condition_id_without_condition`). A table without it names conditions by their folder labels, as before. Never a feature. |
| `condition_id` | FOV table (may also be in the observation table) | string | The condition's ID in the MorphoBricks experiment description, beside the folder label `condition`, which stays the field's identity (experiment-v1 section 3.4; `v33`: the folder `control` has the ID `ctrl`). With it, the paired analyses and the workflows name every condition by its ID, so a control is declared by its ID (`Setup(control={"condition": "ctrl"})`); a control named by a folder label that is not an ID is refused with the ID to use (code `condition_named_by_folder_label`), as is a positive control, a Setup `experiment` mapping, comparisons or a contrast table that names one; a positive control or an `experiment` key that matches no condition is refused, listing the IDs (code `condition_not_found`). `check_tables`, `scan_design`, the overview and the plots read conditions by their IDs too. The outputs keep the folder label beside the ID: the per-repeat rows of the condition contrast gain `folder` and `control_folder` (`DrugA/experiment_23`), the fields to check and the acquisition anomalies' rows (`folder`) name their folders, and the report and its page say once which folders are named by which ID. Each folder must have one ID in every field and each ID one folder (else `PairingRefused`: `condition_id_empty`, `condition_id_split`, `condition_id_merged`, `condition_id_disagrees`, `condition_id_without_condition`). A table without it names conditions by their folder labels, as before. Never a feature. |
| `technical_repeat` | both, or FOV table only | string | Technical repeat within the biological repeat: a well, a dish, a coverslip. Never a biological repeat. A default analysis group and part of field identity. The overview counts technical repeats. Plots shape points by them and resample them before fields. The contrast shuffles whole technical repeats when its smallest p can reach 0.05 after the Bonferroni correction, 4 a side for one contrast. `Setup` derives the hierarchy "field within technical repeat within repeat" from it, for "more fields or more technical repeats?". `single` means one technical repeat per repeat (see [A level with one member](#a-level-with-one-member-single)). |
| `technical_repeat_id` | FOV table | string | The technical repeat's ID in the MorphoBricks experiment description, beside the folder label `technical_repeat`. A shared column: read as metadata, never a feature, and not used for grouping (the technical repeat is identified with its condition and biological repeat). |
| `target` | FOV table (may also be in the observation table) | string | What each condition acts on, for example the gene two siRNAs silence (`CCT8` for `siCCT8#5` and `siCCT8#8`; `non-targeting` for the control). Not a group column. Question 9 then says, per target with two or more reagents, in how many repeats all of them are on the same side of the control; this is described, not tested. One target per condition, or the contrast raises. |
Expand Down
8 changes: 8 additions & 0 deletions docs/common/function_duplicates.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@
"workflows._html_map_text = f\"Under each map: of each observation's {K} nearest neighbours among the other o",
"workflows._label_control = 64"
],
"NOT_ASSESSABLE": [
"workflows._enough_features = 'not assessable'",
"workflows._html_plan_repeats = 'not assessable'"
],
"NOT_ASSESSED": [
"_style = '➖'",
"sampling_unit.reading_text = 'not assessed across repeats'"
],
"NO_CONTROL": [
"_control = 'no control is declared: comparisons are available only for explicitly requested",
"retrospective.effect_preservation = 'not evaluable: no control fields in this repeat'",
Expand Down
Loading
Loading