spacr.qt.widgets.plate_layout¶
Design plate layouts and validate position-related experimental risks.
The module produces a single well-level artifact for acquisition and analysis.
It uses spacr.schema identifiers such as r3, c7, and C07,
allowing exported layouts to join measurement tables on (rowID, columnID)
without a translation step.
check_design() identifies conditions or controls that are confounded
with rows, columns, or edge wells. Edge-only placement is flagged because
evaporation and thermal gradients can make the outer ring systematically
different from the plate interior.
Randomized layouts cannot be represented by the whole-row and whole-column
vocabulary accepted by spacr.utils.annotate_conditions.
to_settings_fragment() therefore refuses to approximate them; the
long-form well table remains the authoritative representation.
Classes¶
One thing being put on the plate. |
|
One thing worth knowing before the plate is poured. |
|
A plate map before the plate exists. |
|
A ready-made design, shipped with spaCR, that a user starts from. |
Functions¶
|
Place every condition's replicates on the plate. |
|
Everything worth saying about a design before it is acquired. |
|
Rebuild a |
|
Findings as plain text, worst first. |
|
Whether a 1-based |
|
|
|
The layouts shipped in |
|
The design as the settings keys the analysis modules already read. |
|
Write the design where the pipeline and the plate handler can read it. |
Module Contents¶
- class spacr.qt.widgets.plate_layout.Condition[source]¶
One thing being put on the plate.
- Variables:
name – label written into the exported table. Becomes the value of
treatment(orhost_cells/pathogen) downstream.replicates – how many wells it gets.
role – one of
ROLES.
- class spacr.qt.widgets.plate_layout.DesignFinding[source]¶
One thing worth knowing before the plate is poured.
- Variables:
key – stable identifier, for tests and for the exported record.
severity –
"error"(the design cannot be laid out),"warn"(it can, and it will cost you), or"note".message – one sentence, naming the wells involved where that helps.
- class spacr.qt.widgets.plate_layout.PlateDesign[source]¶
A plate map before the plate exists.
- Variables:
plate_id – the plate’s name. Written into
plateIDand must match the one the image file names will carry, or the exported table will not join to the measurements.plate_format – well count; a key of
PLATE_FORMATS.conditions – what goes on it.
layout – one of
LAYOUTS.edge_policy –
EDGE_USEorEDGE_LEAVE_EMPTY.seed – makes
randomreproducible. A layout nobody can regenerate is a layout nobody can check, and the plate map is the one record that has to survive the person who made it.
- class spacr.qt.widgets.plate_layout.PlateTemplate[source]¶
A ready-made design, shipped with spaCR, that a user starts from.
- Variables:
key – the file’s stem, stable across releases, e.g.
04_384_crispr_screen. The numeric prefix fixes the menu order.title – the menu entry.
description – what the layout is for and what its findings mean.
design – the design itself; loading a template replaces the form with it apart from the plate name, which stays the user’s.
- spacr.qt.widgets.plate_layout.assign_wells(design: PlateDesign) pandas.DataFrame[source]¶
Place every condition’s replicates on the plate.
- Parameters:
design – the design.
- Returns:
one row per assigned well, with columns
plateID,well,rowID,columnID,row_index,column_index,condition,role,replicateandis_edge. The ids arespacr.schema’s, so the frame joins to a measurements table on(plateID, rowID, columnID).- Raises:
ValueError – when the conditions need more wells than the plate and the edge policy leave usable. Refused rather than truncated: a silently dropped replicate is a plate that does not match its own map.
- spacr.qt.widgets.plate_layout.check_design(design: PlateDesign, table: pandas.DataFrame | None = None) List[DesignFinding][source]¶
Everything worth saying about a design before it is acquired.
Ordered worst first. An empty list means nothing was found, which is not the same as the design being good – there is no check here for whether the biology makes sense.
- Parameters:
design – the design.
table – its assignment, from
assign_wells(). Computed if omitted; pass it in when it has already been built.
- Returns:
findings,
"error"before"warn"before"note".
- spacr.qt.widgets.plate_layout.design_from_record(record: Dict[str, Any]) PlateDesign[source]¶
Rebuild a
PlateDesignfrom the mappingplate_map.jsonholds.The same keys
write_design()writes, so an exported design and a shipped template are read by one function. Missing keys take thePlateDesigndefaults; findings and well counts in the record are ignored, because they are recomputed from the design.- Parameters:
record – the mapping.
- Returns:
the design.
- Raises:
ValueError – when a condition or the design is invalid, with the message the dataclass gives.
- spacr.qt.widgets.plate_layout.format_findings(findings: Sequence[DesignFinding]) str[source]¶
Findings as plain text, worst first.
- Parameters:
findings – layout findings, one output line each in the order given, prefixed
STOP,!or-by severity; an empty sequence gives the no-problems sentence.
- spacr.qt.widgets.plate_layout.is_edge(row: int, column: int, n_rows: int, n_columns: int) bool[source]¶
Whether a 1-based
(row, column)is in the plate’s outer ring.- Parameters:
row – 1-based plate row.
column – 1-based plate column.
n_rows – number of rows on the plate.
n_columns – number of columns on the plate.
- spacr.qt.widgets.plate_layout.plate_shape(plate_format: int) Tuple[int, int][source]¶
(n_rows, n_columns)for a well count.- Parameters:
plate_format – number of wells: 6, 12, 24, 48, 96, 384 or 1536; any other value raises
ValueError.
- spacr.qt.widgets.plate_layout.plate_templates() List[PlateTemplate][source]¶
The layouts shipped in
spacr/resources/plate_templates, in order.Read from package data on every call; the folder holds a handful of small files and is only read when Experiment Design builds its menu. A file that does not parse is skipped rather than raised: one bad template must not take the others off the menu.
- Returns:
every template that loaded, sorted by key.
- spacr.qt.widgets.plate_layout.to_settings_fragment(design: PlateDesign, table: pandas.DataFrame | None = None, *, key: str = 'treatment') Dict[str, Any][source]¶
The design as the settings keys the analysis modules already read.
spacr.utils.annotate_conditionsmaps a condition onto wells through row and column ids, so this can only be produced when each condition occupies whole rows or whole columns. A random layout cannot be written that way, and this returnsexpressible=Falsewith the reason rather than an approximation that would mislabel wells.- Parameters:
design – the design.
table – its assignment; computed if omitted.
key – which settings family to fill –
"treatment","cell"or"pathogen".
- Returns:
{"expressible": bool, "reason": str, "settings": {...}}.settingsholds<key>sand<key>_plate_metadatapluspositive_control/negative_controlwhen those roles are used.
- spacr.qt.widgets.plate_layout.write_design(design: PlateDesign, folder: Any, *, table: pandas.DataFrame | None = None) Dict[str, pathlib.Path][source]¶
Write the design where the pipeline and the plate handler can read it.
Three files, because they have three readers:
plate_map.csv– one row per well, keyed by(plateID, rowID, columnID). The artifact: it joins straight onto a measurements table and it survives a randomised layout, which the settings fragment does not.plate_map.json– the design itself plus its findings, so the layout can be regenerated and so the warnings that were shown are on the record rather than only on somebody’s screen.plate_map_settings.json– thetreatments/treatment_plate_metadatapair to paste into an analysis settings file, when the layout can be expressed that way.
- Parameters:
design – the design.
folder – destination directory; created if absent.
table – its assignment; computed if omitted.
- Returns:
{name: path}for every file written.