spacr.qt.widgets.sweep_panel

One button: every gene against every measurement.

The engine is spacr.gene_measurement_sweep; this is the thin panel over it, and it is thin on purpose – the three corrections that make the answer trustworthy (identifiers excluded, Benjamini-Hochberg across the grid, circularity reported per row) live in the engine so a settings CSV, a macro and this button cannot disagree about them.

IT RUNS OFF THE GUI THREAD, and the reason is today’s crash rather than politeness: a regression built Qt widgets on its own worker and the process segfaulted somewhere else entirely. So the worker here touches NO widget and returns plain data, and the figure is rendered by matplotlib’s Agg canvas which has no Qt object to own.

Classes

SweepPanel

The button, the table, and the picture.

Functions

sweep_inputs(cells, counts, *[, score_column, scores])

(wells, fractions, plates, scores) from a merged frame and counts.

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.QWidget

The 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 False in tests so run finishes before it returns.

  • scores_provider – called for the per-object scores. Separate from cells_provider because 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 None when 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.

save(*_args) → str[source]

Write the whole table – not the page on screen.

selected_gene()[source]

Return the selected gene or the strongest surviving gene.

None is returned when the table contains no suitable gene. The profile title distinguishes the automatic fallback from a row selected by the user.

show_picture(*_args)[source]

Draw the chosen view in its own window. Returns the dialog, or None.

A WINDOW RATHER THAN A PANE, because the Measurements tab is already four sections in a side panel – “there are to many elements in the measurements tab” – and a heatmap of forty measurements needs more width than that column has.

start(*_args) → bool[source]

Run the sweep. Returns whether one was started.

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 pplate1 where its measurements database says plate1, so an un-canonicalised join matches no well at all – and the resulting all-NaN circularity column reads as “nothing here is circular”, which is the most confident possible way to say nothing.

Parameters:
  • cells – the merged per-object frame with plateID, rowID and columnID (or prc); its numeric columns are averaged per well. It is copied, not modified.

  • counts – the per-well gRNA table with prc, grna and fraction columns, pivoted to one column per gRNA.

  • score_column – the score column averaged per well, read from cells or else from scores.

  • scores – an optional score table used when cells lacks score_column.