Skip to content

codex/add-column-for-cell-by-protein-visualization - #245

Open
huanlity wants to merge 1 commit into
mainfrom
codex/add-column-for-cell-by-protein-visualization
Open

codex/add-column-for-cell-by-protein-visualization#245
huanlity wants to merge 1 commit into
mainfrom
codex/add-column-for-cell-by-protein-visualization

Conversation

@huanlity

Copy link
Copy Markdown
Contributor

Summary

  • add protein metadata loader and selection state mirroring the existing gene utilities
  • extend the landscape UI to show a protein column with top-protein bars and callbacks that fetch cbp parquet data
  • clear and synchronize protein selections across deck.gl interactions and reset protein bars on viewport changes

Testing

  • npm run lint:js

https://chatgpt.com/codex/tasks/task_b_68fa1ede6bec8331a305d7785df2f839

@cornhundred

Copy link
Copy Markdown
Collaborator

Review notes: protein section in control panel

Overall: The parallel-section approach is right. Proteins are a separate modality
that still maps onto the same cell-coloring mechanism, so a sibling section next to the
gene section is the natural model. The code mirrors the gene path (meta_gene /
selected_genes / bar callbacks) closely, which makes it easy to follow. The cleanest
part is generalizing update_cell_exp_array to take a feature_store + { dataType }
and switch the cbg/cbp directory — that's the correct shared abstraction. Issues to
address before this is the final shape:

1. No backend/data support exists yet

run_pre_processing.py and dega.pre only produce cbg/ and meta_gene.parquet.
Nothing generates cbp/ or meta_protein.parquet. This branch is frontend-only against
files that don't exist yet — need to decide whether the data-prep side lands first/together.

2. The protein section always renders, even with no protein data

There's no is_protein flag analogous to the existing is_nbhd pattern. set_meta_protein
swallows its error and sets empty arrays, and ui_containers.js unconditionally appends
protein_container. Net effect: every existing dataset now fires a meta_protein.parquet
request that 404s and renders an empty "PRT" section. Most important fix — gate the whole
section on a viz_state.proteins.is_protein flag set from a landscape parameter, mirroring
is_nbhd.

3. Mutual exclusion via scattered manual resets is fragile

"Selecting a protein clears the gene/cat selection" is implemented by sprinkling
update_selected_proteins(viz_state.proteins, [], obs_store) into ~12 call sites (every
gene/cat/nbhd/dendro/search/cgm callback). This was already a smell with genes↔cats; a third
modality makes it combinatorial and easy to miss a site. Consider a single
clear_feature_selections(viz_state, { except }) helper or a single "active feature" concept.

4. Defensive ?. / || [] / || {} everywhere signals uncertain init

Guards like if (viz_state.proteins && ...), top_protein_counts || [], and
if (!viz_state.proteins.svg_bar_protein) suggest uncertainty about init. It is always
initialized (both landscape_ist and landscape_sst). Guarantee init once and drop the
defensive noise — it hides ordering bugs rather than preventing them. The
if (viz_state.obs_store.selected_proteins) guards are also dead since create_obs_store
always creates those observables now.

5. landscape_sst gets the state object but no section

landscape_sst.js initializes viz_state.proteins = {...} but never calls set_meta_protein
and never builds a protein bar. Dead state in the SST path — either wire it up or don't
initialize it there.

6. Smaller things

  • Inconsistent UI construction: the PRT label is a hand-styled inline div, while
    cell/TRX/NBHD use make_button(...). Reuse make_button; also its blue collides with
    the TRX button's blue.
  • No visual gene/protein distinction: get_cell_color returns red [255,0,0] for any
    expression, so protein-colored cells look identical to gene-colored ones. color_dict_protein
    is loaded but only used for bar colors, not cell coloring — decide whether that's intended.
  • max_exp ... ?? 1 fallback in update_cell_exp_array silently changes the gene path:
    a missing meta_gene[gene].max previously threw, now it normalizes to 1.
  • No model sync: selected_genes.js has sync_selected_genes (pushes to the Python widget
    model); there's no sync_selected_proteins. Fine if not needed yet, just flagging the asymmetry.
  • No protein search box to parallel the gene search — bars only.

Bottom line

Keep the parallel-section direction and the feature_store/dataType generalization. Before
merge: (a) an is_protein gate so non-protein datasets are untouched, (b) a centralized
selection-reset rather than scattered manual clears, and (c) a decision on whether the data-prep
side ships alongside. Items 4–6 are cleanup.

@cornhundred cornhundred changed the title Add protein expression column to landscape view codex/add-column-for-cell-by-protein-visualization Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants