Interactive web application for exploring and analyzing scRNA-seq and spatial transcriptomics data. Load an h5ad file, visualize cells on a scatter plot, run Scanpy analysis pipelines, and explore results — all from your browser.
- Python 3.9+
- Node.js 18+
cd xcell/backend
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in editable mode
pip install -e .cd xcell/frontend
npm install# Terminal 1: Start the backend (from xcell/backend/)
uvicorn xcell.main:app --reload
# Terminal 2: Start the frontend (from xcell/frontend/)
npm run devOpen http://localhost:5173 in your browser.
A bundled toy dataset (toy_spatial.h5ad) loads automatically if no data path is specified. To load your own data, set the XCELL_DATA_PATH environment variable:
XCELL_DATA_PATH=/path/to/your/data.h5ad uvicorn xcell.main:app --reloadThe included test_data/toy_spatial.h5ad dataset is a small spatial transcriptomics dataset for exploring XCell's features. Here's a step-by-step walkthrough:
- Pan by clicking and dragging
- Zoom with scroll wheel
- Cells are rendered as points at their spatial coordinates
- Open Cell Manager (left panel)
- Select a metadata column to color cells by that annotation
- Use the lasso tool to draw a selection around cells
- Selected cells can be masked or deleted
- Open the Scanpy modal (top toolbar)
- Go to Preprocessing and run in order:
- Normalize Total — normalize counts per cell
- Log1p — log-transform the data
- Highly Variable Genes — identify informative genes
- In the Scanpy modal, go to Cell Analysis and run in order:
- PCA — reduce dimensionality
- Neighbors — build cell neighborhood graph (requires PCA)
- UMAP — compute 2D embedding (requires Neighbors)
- Leiden — cluster cells (requires Neighbors)
- In Cell Manager, select the
leidencolumn to color by cluster - Switch the embedding to
X_umapto see the UMAP layout
- Open Gene Manager (right panel)
- Search or browse genes
- Click a gene to color cells by its expression
- Create gene sets manually in Gene Manager
- Import gene lists from files
- Expand a categorical column in the Cell Manager (left panel)
- Check the boxes next to the categories you want to compare
- Click the Compare button in the toolbar:
- 2 checked → pairwise differential expression
- 3+ checked → one-vs-rest marker gene analysis
- You can also use lasso selection: select cells → Set as Group 1 / Set as Group 2 → click Compare in the comparison bar
- Draw lines on the scatter plot
- Use the Line Association tool to analyze genes along trajectories
- In the Scanpy modal, go to Gene Analysis:
- Build Gene Graph — compute gene-gene similarity
- Cluster Genes — group genes by expression pattern
- Select genes in the Gene Panel (click individual genes or use a gene set)
- Open the Scanpy modal, go to Spatial Analysis > Contourize
- Adjust smoothing sigma, contour levels, and grid resolution as needed
- Click Run — a new categorical column appears in the Cell Panel
- Color cells by the contour column to visualize spatial expression zones
- Click Load in the toolbar
- Choose Secondary from the "Load into" dropdown
- Browse or enter the path to a second h5ad file and click Load
- A dataset switcher dropdown appears in the header — switch between Primary and Secondary to compare datasets
- Click the Split button to view both datasets side by side
- Click on either plot to make it the active dataset — the Cell and Gene panels update accordingly
- Each plot has its own embedding selector, legend, and independent pan/zoom
- Click Export in the toolbar to download annotations and results
- Interactive scatter plot — deck.gl-powered visualization with pan, zoom, lasso selection
- Cell Manager — browse/color by metadata, mask/delete cells
- Gene Manager — search genes, create gene sets, import gene lists
- Scanpy integration — run preprocessing, cell analysis (PCA, Neighbors, UMAP, Leiden), gene analysis, spatial analysis (contourize), and differential expression directly in the browser
- Trajectory analysis — draw lines and associate genes with spatial trajectories
- Display settings — adjust point size, opacity, colormaps, bivariate coloring
- Multi-dataset support — load two h5ad files, switch between them, or view side by side in split mode
- Export — download annotations and analysis results
xcell/
├── backend/
│ ├── xcell/
│ │ ├── main.py # FastAPI app entry point
│ │ ├── adaptor.py # DataAdaptor class (wraps AnnData)
│ │ ├── diffexp.py # Differential expression
│ │ ├── data/
│ │ │ └── toy_spatial.h5ad # Bundled toy dataset
│ │ └── api/
│ │ └── routes.py # REST API endpoints
│ └── pyproject.toml # Python dependencies
├── frontend/
│ ├── src/
│ │ ├── App.tsx # Main app component
│ │ ├── store.ts # Zustand state management
│ │ ├── main.tsx # Entry point
│ │ ├── components/
│ │ │ ├── ScatterPlot.tsx # deck.gl scatter plot
│ │ │ ├── CellPanel.tsx # Cell metadata manager
│ │ │ ├── GenePanel.tsx # Gene browser / gene sets
│ │ │ ├── ScanpyModal.tsx # Scanpy analysis pipeline UI
│ │ │ ├── DiffExpModal.tsx # Differential expression
│ │ │ ├── LineAssociationModal.tsx # Trajectory analysis
│ │ │ ├── DisplaySettings.tsx # Visualization settings
│ │ │ ├── ShapeManager.tsx # Shape/selection tools
│ │ │ └── ImportModal.tsx # Gene list import
│ │ └── hooks/
│ │ └── useData.ts # Data fetching hooks
│ ├── package.json # Node dependencies
│ └── vite.config.ts # Vite configuration
├── README.md
test_data/
├── toy_spatial.h5ad # Toy dataset for testing
└── generate_toy.py # Script to regenerate toy data
- Backend: FastAPI + AnnData + Scanpy, serving data and running analysis via REST API
- Frontend: React + TypeScript + Vite + deck.gl + Zustand for state management
- Data flow: h5ad file → DataAdaptor → REST API → React hooks → deck.gl visualization
- API docs: Available at http://localhost:8000/docs when the backend is running
