How epigen/cellwhisperer works
1. Overall shape
CellWhisperer is not a single app; it is a repo that combines model code, multiple Snakemake pipelines, dataset curation, evaluation/figure generation, and deployment assets. The main product is a multimodal system for scRNA-seq exploration: transcriptome embeddings plus a chat interface over CELLxGENE.
2. Top-level execution boundaries
The repository separates three major execution modes:
- offline data/model pipelines driven by Snakemake under src/
- Python package runtime under src/cellwhisperer/
- deployment/hosting under hosting/, Dockerfile, and modules/cellxgene
This matters for architecture because most outputs are generated artifacts in resources/ and results/, not source-controlled code.
3. Core embedding package
src/cellwhisperer/ is the main Python library. It contains:
- model definitions for the joint embedding system
- dataset wrappers for training and inference
- loss functions and contrastive objectives
- training entrypoints via PyTorch Lightning
- utilities for inference, model I/O, and processing
This is the central runtime layer used both for training and for generating embeddings for new datasets.
4. Embedding model variants
The package supports multiple transcriptome backbones and variants, including geneformer_model.py, scgpt_model.py, and uce_model.py, plus frozen_model.py and joint embedding orchestration. These are boundary points where the repo adapts external foundation models into a common CellWhisperer interface.
5. Training data engineering
The training corpora are built from several dataset-specific pipelines under src/datasets/ such as ARCHS4/GEO, CELLxGENE Census, Tabula Sapiens, ImmGen, pancreas, bowel disease, and others. Each dataset family has its own Snakemake rules and scripts for downloading, filtering, harmonizing metadata, and producing H5AD-based training inputs.
6. Natural-language annotation pipeline
src/pre_training_processing/ transforms structured single-cell metadata into captions and annotations used for multimodal training. It includes scripts for annotation processing and dataset integration, plus prompts and sample request/response pairs. The README indicates this stage may use GPT-4 when available, or a local Qwen model fallback, so annotation generation is an explicit NLP subpipeline rather than part of the model itself.
7. Joint transcriptome–text training
The contrastive/joint embedding training workflow lives in the cellwhisperer package and is configured through YAML files such as src/cellwhisperer_clip_v1.yaml and the v2 variants. Training is run with the LightningCLI-style cellwhisperer fit ... workflow. Losses and discriminators under src/cellwhisperer/jointemb/loss/ implement the alignment objective between transcriptome and text embeddings.
8. Chat-model pipeline
src/llava/ is a separate training pipeline for the CellWhisperer chat model, built on a modified LLaVA stack. It contains dataset-generation scripts, prompt templates, request/response examples, and Snakemake rules for training. This is architecturally distinct from the embedding model: one subsystem produces vector embeddings, the other powers conversational generation over cell data.
9. User dataset preprocessing for CELLxGENE
src/cellxgene_preprocessing/ is the pipeline that turns a user’s H5AD dataset into a CELLxGENE-ready dataset with CellWhisperer features. It reads raw counts, generates embeddings, annotates clusters, and outputs a processed H5AD used by the browser. This is the main boundary for “bring your own dataset” support.
10. Analysis and paper reproduction
src/figures/ and src/ablation_study/ are downstream analytical pipelines for reproducing manuscript figures, ablations, and validation experiments. They consume outputs from the training and preprocessing stages, often along with precomputed artifacts, and produce the paper’s plots and tables. These directories are analysis consumers rather than production runtime components.
11. Serving and deployment
hosting/ contains the public website and deployment setup, including static pages, nginx configuration, docker compose files, and a dataset-processing Docker setup. src/model_server/ is a lightweight server entrypoint for model-backed functionality. The deployment path also integrates the modified CELLxGENE submodule so the browser can call CellWhisperer-backed services.
12. External dependencies and submodules
modules/ holds git submodules for modified upstream projects: CELLxGENE, LLaVA, Geneformer, and UCE. These are not merely vendored copies; they form explicit architectural seams where the repo extends external ML and browser infrastructure. The repo also depends on external services for hosted AI inference by default, plus optional OpenAI, Hugging Face, and project-hosted dataset/model downloads.
13. Shared infrastructure
src/shared/ centralizes rules and utilities reused across pipelines: model downloads, gene sets, GSVA, sample weights, annotation representations, and transcriptome processing. This layer reduces duplication across dataset prep, training, and evaluation, and is the main cross-cutting dependency among the Snakemake workflows.
Main entry points: Snakefile Main pipeline · jointemb Joint emb · hosting Hosting · cellwhisperer CW package
Components 21
Offline pipelines
Snakemake-driven data preparation, annotation, and analysis workflows.
- Main pipeline · Top-level orchestration for repository-wide offline workflows.
src/Snakefile - Shared core · Reusable processing, model-download, gene-set, and weighting logic shared across pipelines.
src/shared - Training data · Family of dataset-specific Snakemake workflows for building training corpora.
src/datasets - Annotations · Transforms structured metadata into captions and annotations for multimodal training.
src/pre_training_processing - CXG prep · Converts user H5AD data into CELLxGENE-ready datasets with CellWhisperer features.
src/cellxgene_preprocessing - Chat pipeline · Separate conversational model pipeline for cell-data question answering and evaluation.
src/llava - Figures · Manuscript figure generation, validation analysis, and downstream plotting workflows.
src/figures - Ablations · Experimental variants and comparisons used for model ablation studies.
src/ablation_study
Runtime library
Core Python package for joint embeddings, inference, and training.
- CW package · Main runtime library for joint embeddings, training, inference, and model I/O.
src/cellwhisperer - Joint emb · Common interface for transcriptome-text alignment and model orchestration.
src/cellwhisperer/jointemb - Model backbones · Adapters for Geneformer, scGPT, UCE, and frozen backbone variants.
src/cellwhisperer/jointemb - Objectives · Contrastive and discriminator components implementing alignment objectives.
src/cellwhisperer/jointemb/loss - Inference utils · Shared inference, processing, and model serialization helpers.
src/cellwhisperer/utils - Validation · Integration and zero-shot evaluation utilities within the package and repo validation layer.
src/cellwhisperer/validation
Serving and deployment
Hosting, browser integration, and model server entrypoints.
- Model server · Lightweight service entrypoint for model-backed functionality.
src/model_server/main.py - Hosting · Website, nginx, docker compose, and dataset-processing deployment setup.
hosting
External seams
Submodules that extend or adapt upstream projects.
- CELLxGENE · Modified browser and dataset exploration frontend integration seam.
modules/cellxgene - LLaVA · Upstream multimodal generation stack adapted for the chat pipeline.
modules/LLaVA - Geneformer · Upstream transcriptome foundation model adapted as an embedding backbone.
modules/Geneformer - UCE · Upstream transcriptome foundation model adapted as an embedding backbone.
modules/UCE
Other components
- CellWhisperer · Multimodal single-cell exploration system combining embedding models, chat workflows, pipelines, and deployment assets.
Connections 25
- CellWhisperer → Main pipeline: orchestrates · Repository-wide offline workflows start here.
- CellWhisperer → CW package: contains · Core Python library lives under the package path.
- CellWhisperer → Hosting: deploys via · Hosting assets provide browser and service deployment.
- Main pipeline → Shared core: reuses · Common rules and helpers are imported across workflows.
- Main pipeline → Training data: drives · Dataset construction pipelines feed training inputs.
- Main pipeline → Annotations: drives · Annotation preprocessing contributes multimodal captions.
- Main pipeline → CXG prep: drives · Prepares user datasets for browser consumption.
- Main pipeline → Chat pipeline: drives · Chat-model dataset generation and training are pipeline-managed.
- Main pipeline → Figures: drives · Figure and analysis artifacts are generated from pipeline outputs.
- Main pipeline → Ablations: drives · Ablation experiments are executed as offline workflows.
- Shared core → Training data: supports · Dataset workflows depend on shared processing and downloads.
- Shared core → Figures: supports · Analysis notebooks and rules reuse shared utilities.
- Annotations → CW package: feeds · Generated annotations are used in multimodal training.
- Training data → CW package: feeds · Prepared corpora become training and inference inputs.
- CXG prep → Hosting: feeds · Processed H5AD artifacts are consumed by hosted browser workflows.
- Chat pipeline → LLaVA: extends · Chat pipeline is built on a modified LLaVA stack.
- CW package → Joint emb: centers on · Joint embedding subsystem is the main runtime core.
- Joint emb → Model backbones: adapts · Backbone-specific adapters normalize external encoders.
- Joint emb → Objectives: optimizes with · Alignment objectives train the shared embedding space.
- Joint emb → Inference utils: uses · Inference and model I/O helpers support training and serving.
- Joint emb → Validation: evaluates with · Package-level validation checks retrieval and annotation behavior.
- Model backbones → Geneformer: wraps · Geneformer backbone is integrated through an adapter.
- Model backbones → UCE: wraps · UCE backbone is integrated through an adapter.
- Hosting → Model server: includes · Deployment exposes the model server as a service component.
- Hosting → CELLxGENE: integrates · Hosted browser stack uses the modified CELLxGENE seam.