spacr.qt.widgets.measurement_compare_dialog¶
Interactive measurement comparisons for selected cell groups.
The panel delegates grouping and data preparation to
spacr.gene_measurement_compare and statistical-test selection to
spacr.sp_stats. It can be embedded in the Cells tab or opened in a
standalone window without changing the comparison semantics.
Classes¶
A window holding one |
|
Compare measurements between selected cell groups and a reference. |
Module Contents¶
- class spacr.qt.widgets.measurement_compare_dialog.MeasurementCompareDialog(objects, groups: Dict[str, Any], parent: PySide6.QtWidgets.QWidget | None = None, settings: Dict[str, Any] | None = None, databases: Any | None = None, counts: Any | None = None)[source]¶
Bases:
PySide6.QtWidgets.QDialogA window holding one
MeasurementComparePanel.Every parameter is handed straight to
MeasurementComparePanel, which documents what each one means.- Parameters:
objects – object rows for the montage and reference contrasts.
groups – selected group names mapped to object-index values.
parent – parent widget.
settings – run settings saved alongside exported results.
databases – measurement databases available for widening the object table.
counts – per-well counts, used to resolve control wells.
Build the window around one
MeasurementComparePanel.Every argument is handed straight through; the panel documents what each one means.
- Parameters:
objects – object rows for the montage and reference contrasts.
groups – selected group names mapped to object-index values.
parent – parent widget, or
None.settings – run settings saved alongside exported results.
databases – measurement databases available for widening the object table.
counts – per-well counts, used to resolve control wells.
- cancel_the_join(*args)[source]¶
Forwarded to the panel this dialog wraps.
- Parameters:
args – passed straight through.
- Returns:
whatever
MeasurementComparePanelreturns.
- choose_wells(*args)[source]¶
Forwarded to the panel this dialog wraps.
- Parameters:
args – passed straight through.
- Returns:
whatever
MeasurementComparePanelreturns.
- comparison()[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever
MeasurementComparePanelanswers.
- join_the_tables(*args)[source]¶
Forwarded to the panel this dialog wraps.
- Parameters:
args – passed straight through.
- Returns:
whatever
MeasurementComparePanelreturns.
- refresh(*args)[source]¶
Forwarded to the panel this dialog wraps.
- Parameters:
args – passed straight through.
- Returns:
whatever
MeasurementComparePanelreturns.
- save_everything(folder: str = '') dict[source]¶
Forwarded to the panel this dialog wraps.
- Parameters:
folder – where to write everything.
- Returns:
whatever the panel returns.
- property contrast[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever
MeasurementComparePanelanswers.
- property controls[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever
MeasurementComparePanelanswers.
- property kind[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever
MeasurementComparePanelanswers.
- property level[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever
MeasurementComparePanelanswers.
- property measurement[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever the panel answers.
- property report[source]¶
Forwarded to the panel this dialog wraps.
- Returns:
whatever
MeasurementComparePanelanswers.
- class spacr.qt.widgets.measurement_compare_dialog.MeasurementComparePanel(objects, groups: Dict[str, Any], parent: PySide6.QtWidgets.QWidget | None = None, settings: Dict[str, Any] | None = None, databases: Any | None = None, counts: Any | None = None, results: Any | None = None)[source]¶
Bases:
PySide6.QtWidgets.QWidgetCompare measurements between selected cell groups and a reference.
Build the comparison panel: the pickers, the plot and the statistics.
The panel opens with the top hits selected: the top significant guides or genes and the wells that carry them, which the user can change. The regression’s results table gives the hits (
spacr.well_scope._top_hits()); without one, the guides of the montage’s own groups are the selection. The population box then starts on “gRNAs + other datapoints in selected wells”, the derived wells are shown under the controls, and “gRNAs…” / “selected wells…” change either. Nothing to select starts on “All datapoints”, so a panel with no guides still draws what it drew before.The join runs off the GUI thread. It reads every object table out of every attached database and joins them onto the crop rows – measured at 3.2 s for one plate’s 553 objects, so a four-plate screen of 60,000 would block the window for minutes.
The well selection is held as
Nonefor “all of them” rather than as the full list: a well that appears after a re-run should be included, and a stored full list would silently exclude it.- Parameters:
objects – the object rows for the montage and the contrasts.
groups – selected group names mapped to object-index values.
parent – parent widget, or
None.settings – run settings, saved alongside exported results.
databases – measurement databases available for widening the object table.
counts – per-well counts, used to resolve control wells.
results – the regression’s coefficient table, as a frame or a CSV path, for the opening selection.
- apply_workspace_state(state) bool[source]¶
Restore comparison controls without computing or drawing a graph.
Recognized, correctly typed entries are applied independently. Unknown fixed choices are ignored; measurement and class identifiers that are not yet offered remain pending until an ordinary refresh or data update. Selected guide and well identifiers are retained without reading files. An active join owned by this panel is cancelled so its late result cannot replace the restored state. No new join, file read or inference starts. The cached comparison and figure remain unchanged until the next refresh.
- Parameters:
state – mapping returned by
workspace_state(); non-dicts and mappings without usable entries leave the panel unchanged.- Returns:
Trueif at least one usable entry was applied, even if its value was already selected; otherwiseFalse.
- cancel_the_join() bool[source]¶
Request cancellation of the active join without blocking the GUI.
- Returns:
Trueif a join was active.
- choose_wells(*_args) bool[source]¶
Open the well checklist and apply a changed selection.
- Returns:
bool –
Truewhen the accepted selection differs from the previous one;Falsewhen unavailable, cancelled, or unchanged.
- chosen_wells() list | None[source]¶
Return the included wells that remain available.
- Returns:
list of str or None – Selected wells intersected with the current inventory, or
Nonewhen all current and future wells are included.
- closeEvent(event)[source]¶
Request cancellation of active work before closing the panel.
- Parameters:
event – the close event, passed on to the base class after the join worker is asked to shut down.
- comparison()[source]¶
The last comparison computed, if any.
- Returns:
the comparison, or None before one has been run.
- join_the_tables(*_args) str[source]¶
Join attached measurement tables into the panel’s object rows.
- Returns:
str – Empty after a clean join, or a user-facing explanation when a database or object row could not be joined.
- nothing_to_compare_against() str[source]¶
Return why the selected cells have no comparison group.
An empty string means at least two classes are available. When only picked cells were loaded, the message identifies
show all in wellas the setting that adds the unpicked comparison cells.
- save_everything(folder: str = '') dict[source]¶
Write everything into one folder. Returns what was written.
- set_data(objects, groups: Dict[str, Any], settings: Dict[str, Any] | None = None)[source]¶
Point the panel at a new montage. The Graph tab calls this rather than being rebuilt, so a user’s chosen measurement and level survive a re-run.
- Parameters:
objects – the object rows for the montage and the contrasts; its numeric measurement columns fill the measurement menu, and the previous choice is kept when still offered.
groups – selected group names mapped to object-index values; copied.
- set_dependent_frame(frame) None[source]¶
Set the dependent-variable table available to the join action.
- Parameters:
frame (pandas.DataFrame) – Table containing dependent variables and object identifiers or parseable image paths.
- set_selected_guides(guides) None[source]¶
Set selected guides and derive their wells for the current scope.
- Parameters:
guides – the selected guides, stored as strings (
Nonefor none); any explicit well subset is cleared so wells are derived from them.
- set_selected_wells(wells) None[source]¶
Set an explicit well subset;
Nonerestores guide-based derivation.- Parameters:
wells – an explicit well subset, stored as strings, or
Noneto derive the wells from the selected guides.
- wells_on_offer() tuple[source]¶
Return annotated wells in first-occurrence order.
- Returns:
tuple of str – Unique wells represented by the current selected groups.
- workspace_state() dict[source]¶
Return JSON-compatible comparison choices without collecting data.
Combo values are stable identifiers, not translated labels. Pending measurement and class choices remain saved until a later refresh can offer them. Well selections preserve
Nonefor all annotated wells or guide-derived scope wells, respectively; an empty list selects none. Frames, figures, database paths and running jobs are not included.
Nested helpers¶
- MeasurementComparePanel.join_the_tables.work()¶
Off the GUI thread. Returns, never raises: a failed join is a message in the panel, not a traceback in the console.
spacr/qt/widgets/measurement_compare_dialog.py:664