Skip to content

Paulnewling/visualizations tabs - #6

Merged
PaulNewling merged 5 commits into
mainfrom
paulnewling/visualizations-tabs
May 6, 2026
Merged

PaulNewling merged 5 commits into
mainfrom
paulnewling/visualizations-tabs

Conversation

@PaulNewling

@PaulNewling PaulNewling commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds Scatterplot and Histogram tabs to Sequence Properties. Two graph-maker panels read the existing propertiesPf p-frame and pick modality-aware defaults — peptide charge / hydrophobicity in peptide mode; chain "A" CDR3 charge / hydrophobicity in antibody/TCR mode. Sample-axis and entity-axis metadata anchored to the input dataset is pulled in for grouping and filtering, with a self-trace filter that drops this block's own exports.properties re-emission to keep the picker free of duplicates.

Notes

  • Data-model migration Ver_2026_05_05 adds graphStateScatter and graphStateHistogram to BlockData. Default state built via factories so nested layersSettings references stay per-instance.
  • AA fraction column dropped from the pframe — at 50k peptides its 20×N cells alone trip graph-maker's 1M-cell guard. Already excluded from axis pickers via isNumericScalar.
  • R21 / R21a reference line at GRAVY = 0 deferred. Graph-maker has no path to inject significantLines on a data-column axis today; documented in docs/spec-deviations.md as SD-009.

Spec: milaboratory/text#118

Two graph-maker panels read the existing propertiesPf p-frame and pick
modality-aware defaults: peptide charge / hydrophobicity in peptide mode,
chain "A" CDR3 charge / hydrophobicity in antibody/TCR mode. Axis pickers
list every numeric scalar PColumn emitted by the run; the 2-axis AA
fraction column (R7) is excluded.

Model:
- propertiesPfHandle output uses getRelatedColumns + a self-trace
  predicate to drop the blockId-stamped exports.properties duplicates.
- propertiesPfCols output exposes PColumnIdAndSpec[] for default-axis
  lookup.
- Three sections: Properties / Scatterplot / Histogram.
- BlockData migration Ver_2026_05_05 adds graphStateScatter +
  graphStateHistogram (default light-green bin fill).

R21 / R21a reference line at GRAVY = 0 deferred — graph-maker has no
path to inject significantLines on a data-column axis today. Documented
in docs/spec-deviations.md as SD-009.
Match the standard block convention — main page is labeled 'Main', not
the page-content noun.
The previous self-trace predicate filtered every column the workflow
emits — trace.inject stamps every output with this block's trace, so
the predicate excluded our own pCols too, leaving an empty pframe and
breaking the histogram.

Skip the result-pool walk entirely. The pickers no longer pull in
linker / meta columns from the pool; sample-level grouping is tracked
as a follow-up.
Replace createPFrameForGraphs with ctx.createPFrame([...pCols, ...meta]).
The pool walk pulled in this block's own exports.properties — a
trace-stamped re-emission of every column already in propertiesPf —
so the data-mapping picker showed every property twice.

Pull single-axis metadata anchored to the input dataset's two axes
(sample idx 0, entity idx 1) so sample groups / abundance / patient IDs
remain available for grouping, then drop self-trace to keep our own
exports out. Same pattern used by cdr3-spectratype, batch-correction,
cell-type-annotation, dimensionality-reduction, and lead-selection.

Also default the scatterplot to the 'bright' categorical palette.
Two changes that together let the scatterplot stay under graph-maker's
1M-cell guard on real datasets:

- model: drop pl7.app/aaFraction from propertiesPfHandle. Two-axis
  (variantKey × aminoAcid) — ~1M cells alone at 50k peptides. The
  picker already excludes it via isNumericScalar (axesSpec.length === 1),
  so the data was pure overhead.

- ui: drop the entity-key grouping default on the scatter page.
  Pre-selecting axesSpec[0] gave every peptide / clonotype its own
  colour, exploding the palette, legend, and render path on any
  realistically-sized dataset. Sample-axis and entity-axis meta cols
  remain available via the picker.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Scatterplot and Histogram visualizations to the Sequence Properties block, featuring modality-aware defaults for peptide and antibody/TCR data. Key changes include a data model migration to version Ver_2026_05_05 to store graph states, new PFrame and column metadata outputs in the model, and the addition of dedicated UI pages for the charts. Feedback was provided regarding the use of shallow copies for default graph states, which could lead to shared references to nested objects across block instances; using factory functions was suggested as a safer alternative.

Comment thread model/src/dataModel.ts
Comment thread model/src/dataModel.ts
Comment on lines +24 to +25
graphStateScatter: { ...DEFAULT_SCATTER_STATE },
graphStateHistogram: { ...DEFAULT_HISTOGRAM_STATE },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the factory functions to initialize the graph states to avoid shared references to nested objects.

Suggested change
graphStateScatter: { ...DEFAULT_SCATTER_STATE },
graphStateHistogram: { ...DEFAULT_HISTOGRAM_STATE },
graphStateScatter: createDefaultScatterState(),
graphStateHistogram: createDefaultHistogramState(),

Comment thread model/src/dataModel.ts
@PaulNewling
PaulNewling marked this pull request as ready for review May 6, 2026 22:35
@PaulNewling
PaulNewling added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit ba3459b May 6, 2026
9 checks passed
@PaulNewling
PaulNewling deleted the paulnewling/visualizations-tabs branch May 6, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant