Skip to content

[FEATURE] Frontend: render EAT predicted-by-transfer annotations (value-level overlay) #277

Description

@tsenoner

Summary

Render the per-cell Embedding Annotation Transfer (EAT) predictions that the backend now writes into .parquetbundle files as a new value-level "predicted-by-transfer" layer in the web app — distinct from, and orthogonal to, PR #272's column-level ⚡ "predicted-by-model" badge.

This is the frontend follow-up to the backend work in tsenoner/protspace#55 (concept: tsenoner/protspace#54).

Background — the two orthogonal axes

  • Axis A (existing, feat(annotations): mark predictions and surface per-annotation docs #272): column-level — "this whole annotation column is a model output" (Biocentral/Phobius/TED). Keep the ⚡ badge / source grouping / info-popover unchanged.
  • Axis B (new, this issue): cell-level — "this specific protein's value in column COL was transferred from a neighbour, with confidence X and source Y."

Never overload the ⚡ badge to mean both.

What the backend now emits

For each transferred column COL, protspace transfer appends three columns to the bundle's annotations table (the curated COL is left untouched; protein_id id column preserved → backward compatible):

Column Type Meaning
COL__pred_value string the transferred label
COL__pred_confidence float32 reliability index in [0, 1]
COL__pred_source string nearest reference protein id

A cell is predicted for COL when COL is empty/blank but COL__pred_value is non-null.

UX (from design spec §9)

  1. Scatter — primary cue is shape, not colour: predicted cells render as hollow (outline-only) markers in the same category hue; observed cells stay filled. Confidence → opacity ramp (alpha = lerp(0.25, 0.9, confidence)), optionally size; desaturate toward grey below ~0.3. Never colour-only (accessibility).
  2. Tooltip — provenance line, e.g. ⚡ Predicted: Neurotoxin (82%) — transferred from P12345 via ProtT5, k=1, with an inline confidence bar and the source id as a click-to-select target.
  3. Legend — a separate "Predicted (transferred)" sub-section (filled "Observed" / hollow "Predicted by EAT" swatches + live counts). Do not merge into the ⚡ header badge.
  4. Global control — "Show predicted annotations" toggle + confidence-threshold slider (High >80 / Med 50–80 / Low <50); below-threshold cells fade rather than vanish; persist in legend settings.

Concrete hooks

  • packages/utils/src/types.ts — add optional annotation_predicted (parallel to annotation_scores / annotation_evidence).
  • packages/core/src/components/data-loader/utils/bundle.ts — detect *__pred_* columns, pivot into the data model (old bundles lack them → no overlay).
  • packages/core/src/components/scatter-plot/style-getters.tsgetOpacity / getPointShape branch on predicted cell + confidence.
  • packages/core/src/components/scatter-plot/webgl-renderer.tsa_predicted attribute + hollow/ring render (reuse the edge-distance math, strokeWidth = 0.15).
  • packages/core/src/components/scatter-plot/protein-tooltip.ts — provenance line + clickable source.
  • packages/core/src/components/legend/legend-renderer.ts — "Predicted (transferred)" sub-section.

Process

Acceptance criteria

  • Bundle parser surfaces predicted value / confidence / source per cell.
  • Scatter shows hollow markers + confidence opacity for predicted cells; observed cells unchanged.
  • Tooltip shows provenance with a clickable source id.
  • Legend "Predicted (transferred)" sub-section with counts.
  • Global toggle + confidence-threshold slider; persisted in settings.
  • Grayscale/PNG export keeps the hollow-vs-filled distinction.
  • Accessibility: non-colour encoding; keyboard-operable slider.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions