Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
92b478b
#578 Glossary: describe the sign-flip test as magnitude-keeping, exac…
claude Nov 25, 2026
2377afb
#418 robust_sd geometry rule: a 1-D sample of one value has no spread…
claude Nov 25, 2026
0a6b1d1
#544 Refuse imaged areas whose total overflows, in the estimator and …
claude Nov 25, 2026
a68d88f
#538 Refuse stage coordinates a float cannot hold: overflow as not fi…
claude Nov 25, 2026
896ea78
#528 repeat_effect: refuse a level outside (0, 1) and infinite per-re…
claude Nov 25, 2026
c57f4ed
#491 Whole-table tests: refuse permutations below 1 (no p from zero d…
claude Nov 25, 2026
67b3023
#495 Feature transforms: refuse boolean/text weights, a non-boolean i…
claude Nov 25, 2026
549fcfb
#485 Feature tables: refuse complex columns before a float cast drops…
claude Nov 25, 2026
af20ae7
#532 Descriptor resamples: refuse empty input, k=0, no resamples and …
claude Nov 25, 2026
553bf89
#551 document: compare Setups' contrast tables by their values instea…
claude Nov 25, 2026
d6bf01e
#581 FrozenDict/FrozenList freeze their contents when built directly,…
claude Nov 25, 2026
5a54d0f
#430 JCB planning: refuse sample keys that hold both control and trea…
claude Nov 25, 2026
b9c4469
#448 Guided controls: ask again for colliding or empty treatment keys…
claude Nov 25, 2026
2b36685
#449 Detection-adjusted bound: read group labels by column name, not …
claude Nov 25, 2026
f90238c
#547 Benchmark rows export each outcome metric's config id as outcome…
claude Nov 25, 2026
7701320
#591 Benchmark Colab notebook: keep the GitHub token out of the clone…
claude Nov 25, 2026
5ce6333
#583 Reference check: validate job kinds and names, refuse duplicates…
claude Nov 25, 2026
e33054f
#577 Lab converters: hash the source archive in chunks instead of rea…
claude Nov 25, 2026
8ba1eeb
#576 Lab converters: refuse fractional, negative or non-finite repeat…
claude Nov 25, 2026
e8c64bb
#640 Workflows example notebook: pair the positive control by repeat_…
claude Nov 25, 2026
ca44b10
#574 Glioma card: say Unique_ID and File_name are not checked by conv…
claude Nov 25, 2026
b6319b6
#569 JCS effect bands: symmetric interval overlap, inverted quartiles…
claude Nov 25, 2026
a0392ef
#520 Benchmark run: stop when P0 fails instead of running the other m…
claude Nov 25, 2026
393e4cd
#524 Semi-synthetic split: refuse repeats without 2 fields and shifts…
claude Nov 25, 2026
bef1cac
#519 P3 exact sign-flip tests: refuse more than 16 repeats instead of…
claude Nov 25, 2026
be5ed93
#514 Fixed-block contrasts: refuse weights that are not a zero-sum co…
claude Nov 25, 2026
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
114 changes: 114 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,120 @@ inventory's, not the Stage 2 MC-1/MC-2 of the experiment description.

### Fixed

- **#514.** The benchmark's fixed-block contrast engine (`candidates/fixed_block.py`) refuses
weights that are not a contrast (`check_weights`: finite real numbers, at least two not 0,
summing to 0) in `regime`, `graph_estimable`, `Layout.contrast`, `fit_model` and
`contrast`: `{"A": 1.0}` was tested as A's mean by the direct test and as A minus the
baseline by the model. Zero-sum weights, rescaled or not, are unchanged.
- **#519.** The benchmark's exact sign-flip tests (`candidates/hd_tests.py`: `sign_flip_u`,
`shrinkage_hotelling`) refuse more than 16 repeats (`MAX_EXACT_REPEATS`) instead of
building all 2**n sign assignments in memory (n = 25 needed more than 800 MB for the signs
alone). Up to 16 repeats, and the benchmark's 3-6, they are enumerated as before.
- **#524.** The benchmark's `semi_synthetic` (`data/simulations/decisions/embedding.py`)
refuses a repeat of fewer than 2 fields (it got no treated field), a shift asked of values
that do not vary (it gave a zero shift), values that are not finite and values and
metadata of different lengths; a draw of two rows that cancel is drawn again instead of
giving a zero direction. Draws that do not cancel are unchanged.
- **#520.** The benchmark's `colab.run` stops with an error when P0 (the deterministic tests)
fails, naming its report, instead of discarding pytest's exit code and running P1-P5 as if
the gate had passed.
- **#569.** `data/crick_idr/jcs_effect_fovs.py` judges two IQR bands as overlapping only when
they intersect (`bands_overlap`, endpoints included), whichever is higher: a band wholly
below the other read as overlapping. Inverted or missing quartiles are refused. The
committed `results/jcs_effect_fovs_pairs.csv` is unchanged (all 400 rows agree).
- **#574.** The glioma dataset card (`data/lab/cct7_cct8_glioma_cdm_tracks/card.toml`) no
longer says that `Unique_ID` and `File_name` are checked by `convert.py`: the converter
never reads them, so the card now says they are not checked; `experiment_nb` is checked
against `Repeat`, as before. Their format was not reconstructed (the owner's source is not
in the repository); the stored tables are unchanged.
- **#640 (part).** The workflows example notebook pairs the positive control's fields by
`repeat_group` (`pair_cols=("repeat_group",)`), not by the folder label
`biological_repeat`, and stops with what to add when the FOV table has no `repeat_group`.
Run on the bundled idr0028 example, the report assesses the positive control. The
notebook's analysis groups are unchanged (the workflows already read each folder label as
its repeat group).
- **#576.** The lab converters read the source's `Repeat`, the glioma `TRACK_ID` and the
filopodia count through `convert_tools.whole_numbers`, which stops, naming the source
rows, unless every value is a finite whole number of at least 1 (repeats) or 0 (track IDs,
counts): `astype(int)` truncated a repeat of 1.8 to 1 and a count of 5.9 to 5. The stored
tables hold only such values (repeats 1-3, track IDs from 1, counts from 7).
- **#577.** The lab converters hash a downloaded source archive in chunks
(`hashlib.file_digest`) instead of reading it whole into memory (381 MB for CCT8 CDM
morphology); the md5 and the member's sha256 are checked as before.
- **#583.** The reference check (`data/reference/reference.py`) refuses a job whose kind is
not one it runs or whose name is not one plain word (a separator, `.` or `..`), and a job
listed twice, before anything runs; the owner's job names are checked the same way, and
`run_job` refuses a target outside `OUT` before removing it. A job list could make it
remove a folder outside `OUT` (`../.. victim`).
- **#591.** The benchmark's Colab notebook (`data/simulations/decisions/benchmark_colab.ipynb`)
no longer puts the GitHub token in the clone URL, where it was in the command, in the
clone's `.git/config` and in the error of a failed clone: git reads it through a
`GIT_ASKPASS` helper from the clone's environment, the remote is checked to be the
token-free URL, and a failed clone raises with git's message (token masked), not the
command. A clone made by the earlier cell keeps the token in
`/content/MorphoCoverage/.git/config` until that Colab session ends.
- **#547.** `BenchmarkRecord.as_row` (and so `records_to_frame`) exports each outcome
metric's config id as `outcome_id.<name>` beside `outcome.<name>`: two metrics given the
same label (`RelativeMeanError("feature_a", label="readout_error")` and the same for
`feature_b`) could not be told apart once exported. The existing columns are unchanged.
- **#449.** The detection-adjusted unseen-state bound names each group by reading its rows by
column name: a group column that is not a Python identifier (`"plate id"`, `"class"`)
raised `AttributeError`, since `itertuples` renames it, whenever an adjusted bound was
available. The bound and its wording are unchanged.
- **#448.** The guided session asks again, instead of keeping only the last condition, when
treatment keys entered for one control repeat or are empty, and when a condition given a
control later finds both its proposed key and its own name taken under that control (the
condition holding the key was overwritten). Every condition assigned to a control is kept.
- **#430.** `plan_objects_to_average` refuses `sample_cols` under which one sample holds
both control and other cells, naming the samples: each was centred on its own mean, so the
treatment's shift entered the within-sample SD (a plan of 107 cells instead of 1 in the
issue's example). Add the column that tells them apart, such as the condition.
- **#581.** A `FrozenDict` or `FrozenList` built by its constructor now freezes what it is
given, so `freeze`, which returns such a container unchanged, no longer keeps a caller's
inner list or dict that could still change a snapshot. Pickling, copying and `freeze` of
plain containers behave as before.
- **#551.** `document` compares the parts' Setups field by field with a contrast table
compared by its values (`DataFrame.equals`): a Setup declared with `contrasts=` raised
"the truth value of a DataFrame is ambiguous" even against itself. Different contrast
tables are still refused as different Setups.
- **#532.** The descriptor-spread resample helpers (`strategies._descriptor_resamples`)
refuse with a `ValueError` what they cannot resample: no value (a `ZeroDivisionError`
before), no FOV, no resample, or positions that are not one FOV of `k` per value. Their
caller, `DescriptorSpreadEstimator`, already reports these cases as not yet possible, so
no result changes.
- **#485.** A complex column of another feature table is refused by `attach_feature_tables`
("has complex columns"), before any float cast dropped its imaginary part: an infinity in
the imaginary part went unseen and a varying one was listed as constant. Nullable real
columns are read as before.
- **#495.** `ColumnWeights` refuses booleans and text as weights (`True` became 1.0 and
`"2.0"` 2.0 through `float`); `BlockWeights` refuses an `inertia_radius` that is not a
boolean (the text `"False"` turned the radius correction on while its provenance said
`"False"`) and block feature names that are not non-empty text (they were recast with
`str`). Valid settings give the same results.
- **#491.** `whole_table_tests` refuses `permutations` that is not an integer of at least 1
(0 drew no shuffle and still gave `p_shuffle = 1.0`; negative, fractional, boolean and
text values were not checked) and a `random_state` that is not a non-negative integer.
- **#528.** `repeat_effect` refuses a `level` outside (0, 1) (1 gave an infinite interval, a
negative level an invalid quantile) and an infinite per-repeat contrast (it gave NaN bounds
after runtime warnings). A missing contrast still gives no interval (NaN), as documented.
- **#538.** Stage coordinates a float cannot hold are refused with the contract's
`ValueError`: a Python integer too large for a float (it raised a bare `OverflowError`) as
not finite, and an integer beyond 2**53 that a float would round (`2**53` and `2**53 + 1`
became one position) as not held exactly, in `stage_matrix` and `check_xy` alike. Nothing
is rounded or rescaled.
- **#544.** Imaged areas that are each finite but whose total overflows a float (two fields
of `1e308`) are now a problem of `_areas.area_problem`: `ImagedAreaEstimator` reports the
area `not_applicable` with that reason, so `FixedAreaStrategy` no longer stops on an
infinite total, and a benchmark refuses the dataset instead of recording an infinite
`area`/`total_area`.
- **#418.** `robust_sd(values, "geometry")` of a 1-D sample of one value returns 0 (no
spread) instead of raising `IndexError`: `constant_columns` sized its zero SD by a second
axis that a 1-D sample does not have.
- **#578.** The glossary's "Sign-flip test" no longer calls it "the exact test on the signs":
it is a two-sided paired permutation test on the mean of the per-repeat differences, each
difference keeping its magnitude while its sign is flipped, exact up to 16 repeats and
Monte Carlo (20,000 assignments) above, as `sign_flip_test` computes it. The source is
`glossary.py`; `docs/common/glossary.md` is re-rendered from it. The test is unchanged.
- **#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,
Expand Down
12 changes: 11 additions & 1 deletion data/crick_idr/jcs_effect_fovs.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ def full_wells(name: str) -> dict[str, float]:
return {c: jcs_effect_size(np.concatenate(f), ctrl) for c, f in treated.items()}


def bands_overlap(a: tuple[float, float], b: tuple[float, float]) -> bool:
"""Whether two IQR bands ``(q25, q75)`` share a point, endpoints included, whichever is
higher: a band wholly below the other does not overlap it (#569). A band with a missing
or inverted quartile is refused."""
for band in (a, b):
if not band[0] <= band[1]:
raise ValueError(f"an IQR band needs q25 <= q75, not {band}")
return bool(max(a[0], b[0]) <= min(a[1], b[1]))


def compare(table: pd.DataFrame, name: str) -> pd.DataFrame:
"""For each compared pair: band overlap, and how often a sample ranks them as the wells do."""
_, _, _, pairs, _ = PAPER[name]
Expand All @@ -150,7 +160,7 @@ def compare(table: pd.DataFrame, name: str) -> pd.DataFrame:
"n_objects": n,
"pair": f"{high} > {low}",
"full_well_difference": reference[high] - reference[low],
"bands_overlap": bool(a.q25 <= b.q75),
"bands_overlap": bands_overlap((a.q25, a.q75), (b.q25, b.q75)),
# draws are independent, so compare every pair of draws
"share_ranked_as_full_wells": float(
np.mean(a["values"][:, None] > b["values"][None, :])
Expand Down
2 changes: 1 addition & 1 deletion data/lab/cct7_cct8_glioma_cdm_tracks/card.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ duplicated_tracks = 28

[columns]
renamed = { Condition = "condition (siCTRL_CCT7 and siCTRL_CCT8 written siCTRL) and source_condition (verbatim)", Repeat = "biological_repeat (as '<set>_<Repeat>')", TRACK_ID = "label_id", File_name_raw = "source_file, and technical_repeat + position_id parsed from it" }
dropped = ["Unique_ID, File_name and experiment_nb: each is a concatenation of kept columns (checked by convert.py)"]
dropped = ["Unique_ID and File_name: source identifiers, not checked by convert.py, which does not read them, so a disagreement with Condition, Repeat, TRACK_ID or File_name_raw would not be found", "experiment_nb: 'R' followed by Repeat (checked by convert.py)"]
added = ["target (the gene the siRNA silences; non-targeting for siCTRL)", "experiment (from the siRNA label)", "image_file (unrecorded)", "source_row (file line, 1 = header)"]
features = { "Mean Speed" = "mean instantaneous speed along the track (px per 10 min)", "Directionality" = "net displacement / path length (1 = straight)", "Tortuosity" = "path length / net displacement", "Total Distance Traveled" = "path length (px)", "Spatial Coverage" = "area explored by the track (px^2)", "Total Turning Angle" = "sum of turning angles (degrees)", "Rolling" = "the same metric on a rolling window along the track (CellTracksColab)" }

Expand Down
12 changes: 9 additions & 3 deletions data/lab/cct7_cct8_glioma_cdm_tracks/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE.parent))
# The shared helpers live one folder up.
from convert_tools import check_columns, check_member, sirna_target, write_csv_gz
from convert_tools import (
check_columns,
check_member,
sirna_target,
whole_numbers,
write_csv_gz,
)

MEMBER = "Tracking_data_CCT8_CCT7_silencing_Glioma.csv"
MEMBER_SHA256 = "dec991b3fdd52956d01ee64c2348ee4ec64afe4f16b7d0f67c549350b064233e"
Expand Down Expand Up @@ -92,12 +98,12 @@ def build_tables(source: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame]:
{
"experiment": experiment,
"condition": source["Condition"].where(~control, "siCTRL"),
"biological_repeat": experiment + "_" + source["Repeat"].astype(int).astype(str),
"biological_repeat": experiment + "_" + whole_numbers(source, "Repeat", 1).astype(str),
"technical_repeat": names["well"],
"position_id": names["well"] + "_" + names["position"],
"image_file": UNRECORDED,
"target": source["Condition"].where(~control, "siCTRL").map(sirna_target),
"label_id": source["TRACK_ID"].astype(int),
"label_id": whole_numbers(source, "TRACK_ID", 0),
**{metric: source[metric] for metric in METRICS},
"source_condition": source["Condition"],
"source_file": source["File_name_raw"],
Expand Down
3 changes: 2 additions & 1 deletion data/lab/cct8_cdm_morphology/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
fetch_zip_member,
sirna_target,
synthetic_positions,
whole_numbers,
write_csv_gz,
)

Expand Down Expand Up @@ -83,7 +84,7 @@ def build_tables(source: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame]:
"""
table = source.rename(columns={"Condition": "condition", **RENAMED})
table["condition"] = table["condition"].astype(str)
table["biological_repeat"] = source["Repeat"].astype(int).astype(str)
table["biological_repeat"] = whole_numbers(source, "Repeat", 1).astype(str)
table["technical_repeat"] = SINGLE
table["image_file"] = UNRECORDED
table["label_id"] = 1
Expand Down
5 changes: 3 additions & 2 deletions data/lab/cct8_filopodia_screen/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
fetch_zip_member,
sirna_target,
synthetic_positions,
whole_numbers,
write_csv_gz,
)

Expand Down Expand Up @@ -82,11 +83,11 @@ def build_tables(source: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame]:
"condition": source["Condition"].astype(str),
"biological_repeat": source["dataset"].astype(str)
+ "_"
+ source["Repeat"].astype(int).astype(str),
+ whole_numbers(source, "Repeat", 1).astype(str),
"technical_repeat": SINGLE,
"image_file": UNRECORDED,
"label_id": 1,
FEATURE: source[FEATURE].astype(int),
FEATURE: whole_numbers(source, FEATURE, 0),
"source_row": source["source_row"].astype(int),
}
)
Expand Down
26 changes: 24 additions & 2 deletions data/lab/convert_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import zipfile
from pathlib import Path

import numpy as np
import pandas as pd


Expand All @@ -22,11 +23,13 @@ def sha256(data: bytes) -> str:


def fetch_zip_member(url: str, archive_md5: str, member: str) -> bytes:
"""``member``'s bytes from the zip archive at ``url``, the archive's md5 verified."""
"""``member``'s bytes from the zip archive at ``url``, the archive's md5 verified, in
chunks: the archive (hundreds of MB) is never held in memory whole (#577)."""
with tempfile.TemporaryDirectory() as tmp:
path = Path(tmp) / "archive.zip"
urllib.request.urlretrieve(url, path)
md5 = hashlib.md5(path.read_bytes()).hexdigest()
with open(path, "rb") as handle:
md5 = hashlib.file_digest(handle, "md5").hexdigest()
if md5 != archive_md5:
raise SystemExit(f"{url}: md5 {md5}, expected {archive_md5}")
with zipfile.ZipFile(path) as archive:
Expand All @@ -48,6 +51,25 @@ def check_columns(source: pd.DataFrame, expected: list[str]) -> None:
raise SystemExit("the source has missing values")


def whole_numbers(source: pd.DataFrame, column: str, minimum: int) -> pd.Series:
"""``source[column]`` as integers; stops unless every value is a finite whole number of at
least ``minimum``, naming the source rows: ``astype(int)`` would truncate a repeat of
1.8 to 1 or a count of 5.9 to 5 (#576)."""
values = source[column]
if pd.api.types.is_bool_dtype(values) or not pd.api.types.is_numeric_dtype(values):
raise SystemExit(f"{column}: {values.dtype} values, not numbers")
numbers = values.to_numpy(dtype=float)
bad = ~np.isfinite(numbers) | (numbers != np.round(numbers)) | (numbers < minimum)
if bad.any():
rows = source["source_row"] if "source_row" in source else pd.Series(source.index)
shown = "; ".join(
f"row {row}: {value}"
for row, value in zip(rows.to_numpy()[bad][:3], values.to_numpy()[bad][:3])
)
raise SystemExit(f"{column}: not a whole number of at least {minimum} in {shown}")
return values.astype(int)


def synthetic_positions(table: pd.DataFrame, group: list[str], order: str) -> pd.Series:
"""A stable field identifier per row, ``<group values>|cellNNN``, numbered by ``order``.

Expand Down
Loading
Loading