Skip to content

Conversation

@cornhundred
Copy link
Collaborator

No description provided.

… recreation with unique IDs. Update make_image_layers and make_simple_image_layer functions to include dataset index and cache key for improved layer handling.
@cornhundred cornhundred changed the title Dataset dropdown opus 2 dataset_dropdown_opus Dec 4, 2025
@cornhundred
Copy link
Collaborator Author

Pull Request Overview: Multi-Dataset Support with Dropdown Selector
Summary
This PR adds support for visualizing multiple datasets in the Landscape widget with an efficient dropdown-based switching mechanism that reuses the existing deck.gl context instead of rebuilding the visualization from scratch.
New Files (untracked, need to be added)

  1. js/ui/dataset_dropdown.js (~94 lines)
    Creates a compact dropdown UI for dataset selection:
    Small dropdown (55px width) that expands on focus/click
    Shows short labels with full names on hover (tooltip)
    Handles async dataset switching with loading state
    Subscribes to current_dataset_index observable to stay in sync
  2. js/ui/switch_dataset.js (~284 lines)
    Core logic for efficient dataset switching:
    State persistence: Saves/restores selected genes, clusters, image visibility, and UMAP/spatial view across dataset switches
    Layer updates: Clones deck.gl layers with new data and unique IDs instead of recreating them
    Cache invalidation: Properly disposes old image layers and creates new ones with unique cache keys
    Data reloading: Fetches new landscape_parameters, cell_metadata, cluster_metadata, meta_gene, etc.
    Modified Files
  3. src/celldega/viz/widget.py (+62 lines)
    Python widget changes:
    New base_urls traitlet: Accepts list of {'url': str, 'label': str} dicts
    New cell_name_prefix traitlet: When True, trims dataset prefix from cell names (e.g., "dataset-name_cell-name" → "cell-name") to map correctly to LandscapeFiles
    Automatic conversion of various input formats (single URL, list of URLs, list of dicts) to standardized format
    Cell name prefix trimming applied to both meta_cell and UMAP data
  4. js/widget.js (+6 lines)
    Passes new base_urls and cell_name_prefix parameters from Python model to landscape_ist.
  5. js/viz/landscape_ist.js (+8 lines)
    Accepts base_urls and cell_name_prefix parameters
    Stores them in viz_state for use by dataset switching logic
  6. js/obs_store/obs_store.js (+3 lines)
    New observables for dataset management:
    current_dataset_index: Tracks which dataset is currently displayed
    dataset_switching: Flag to prevent concurrent switches and disable certain updates during transitions
  7. js/ui/ui_containers.js (+7 lines)
    Integrates the dataset dropdown into the image controls section of the UI.
    Key Features
    Multiple Dataset Support: Pass a list of URLs to base_url parameter
    Efficient Switching: No WebGL context accumulation - reuses existing deck.gl instance
    State Persistence: Selected genes/clusters, image visibility, and view mode persist across dataset switches (only valid selections for new dataset are restored)
    Cell Name Prefix Handling: Supports datasets where cell names have been prefixed for uniqueness
    Improved UX: Dropdown expands on interaction, shows tooltips with full dataset names
    Usage Example
    landscape = dega.viz.Landscape( technology='Xenium', base_url=[ {'url': 'https://bucket/dataset1/', 'label': 'Sample A'}, {'url': 'https://bucket/dataset2/', 'label': 'Sample B'}, ], adata=adata, cell_name_prefix=True, # If cell names have dataset prefixes height=500,)
    Bug Fixes (in working directory, may need commit)
    Fixed gene click from Clustergram causing solid red cells on first click (reordered update_selected_cats to run after update_cell_exp_array)
    Converted camelCase variables to snake_case for consistency
    Note: The new files dataset_dropdown.js and switch_dataset.js are currently untracked and need to be staged/committed.

@cornhundred cornhundred requested a review from huanlity December 11, 2025 03:10
@cornhundred
Copy link
Collaborator Author

cornhundred commented Dec 11, 2025

@jaspreetishar and @huanlity - you all can follow this example to test locally https://colab.research.google.com/drive/1VBJUNQoldIjpWxyUOdSd7oIOThpC5mri?usp=sharing

Copy link
Contributor

@huanlity huanlity left a comment

Choose a reason for hiding this comment

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

Works great on my end. Two unexpected things I found are:

  1. if you turn off IMG and change the dataset, the new dataset will still display the underlying IMG.
  2. While 1 is happening, the IMG sign is greyed out.

Fixing either one would work but fixing 1 will be better IMO.

@cornhundred
Copy link
Collaborator Author

@huanlity I'm ok fixing this in a subsequent pull request because we have several other pull requests that build off of this one and I want them to not diverge too much.

@cornhundred cornhundred marked this pull request as ready for review December 11, 2025 13:20
@cornhundred cornhundred merged commit 3b7ff0c into main Dec 11, 2025
10 checks passed
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.

3 participants