spacr.qt.widgets.sweep_panel¶
Panel that sweeps every gene against every measurement.
The engine is spacr.gene_measurement_sweep; this is a thin panel over
it. The three corrections the sweep applies (identifiers excluded,
Benjamini-Hochberg across the grid, circularity reported per row) live in the
engine, so a settings CSV, a macro and this button apply them identically.
The sweep runs off the GUI thread. Qt widgets built on a worker thread can crash the process, so the worker touches no widget and returns plain data, and the figure is rendered by matplotlib’s Agg canvas, which owns no Qt object.
Classes¶
The button, the table, and the picture. |
Functions¶
|
|
Module Contents¶
- class spacr.qt.widgets.sweep_panel.SweepPanel(cells_provider: Callable | None = None, counts_provider: Callable | None = None, parent: PySide6.QtWidgets.QWidget | None = None, *, threaded: bool = True, scores_provider: Callable | None = None)[source]¶
Bases:
PySide6.QtWidgets.QWidgetThe button, the table, and the picture.
The providers are CALLED when a sweep runs rather than read at construction, so the panel always sweeps what is on screen now.
- Parameters:
cells_provider – called for the cell table to sweep.
counts_provider – called for the per-well counts.
parent – parent widget.
threaded – whether the sweep runs off the GUI thread. False runs it inline, which is what a test wants.
scores_provider – called for the scores, when the sweep needs them.
Build the gene-sweep panel.
- Parameters:
cells_provider – called for the per-object measurements.
counts_provider – called for the well or guide counts.
parent – parent widget, or
None.threaded – run the sweep on a worker thread. Set
Falsein tests sorunfinishes before it returns.scores_provider – called for the per-object scores. Separate from
cells_providerbecause the merged measurements frame has no prediction column – it is the measurement tables – so without this circularity comes out NaN and the panel says so rather than showing zeros.
- closeEvent(event)[source]¶
Stop background work and unlink before going away.
- Parameters:
event – the Qt close event.
- exclusions() dict[source]¶
Return active exclusion controls as
sweep()arguments.Blank controls are omitted so they mean “no filter” rather than a filter whose value matches nothing.
- figure(path: str | None = None, kind: str | None = None)[source]¶
One picture of the sweep, or
Nonewhen there is nothing to draw.- Parameters:
kind – one of
PICTURES; the chooser’s current pick by default.
- rows() pandas.DataFrame[source]¶
What the table is showing, as a frame.
- selected_gene()[source]¶
Return the selected gene or the strongest surviving gene.
Noneis returned when the table contains no suitable gene. The profile title distinguishes the automatic fallback from a row selected by the user.
- spacr.qt.widgets.sweep_panel.sweep_inputs(cells, counts, *, score_column: str = 'pred', scores=None)[source]¶
(wells, fractions, plates, scores)from a merged frame and counts.The plate names are canonicalised on both sides. A score CSV of the real screen says
pplate1where its measurements database saysplate1, so an un-canonicalised join matches no well at all, and the resulting all-NaN circularity column would read as “nothing here is circular”.- Parameters:
cells – the merged per-object frame with
plateID,rowIDandcolumnID(orprc); its numeric columns are averaged per well. It is copied, not modified.counts – the per-well gRNA table with
prc,grnaandfractioncolumns, pivoted to one column per gRNA.score_column – the score column averaged per well, read from
cellsor else fromscores.scores – an optional score table used when
cellslacksscore_column.