|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a MultiQC plugin that extends the core Xenium module with computationally intensive analyses for Xenium spatial transcriptomics data. It processes large parquet and H5 files that the core module skips for performance reasons. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Install for development |
| 12 | + |
| 13 | +```bash |
| 14 | +pip install -e . |
| 15 | +``` |
| 16 | + |
| 17 | +### Run linting |
| 18 | + |
| 19 | +```bash |
| 20 | +pre-commit run --all-files |
| 21 | +``` |
| 22 | + |
| 23 | +Uses ruff for formatting and linting (line-length: 120, target: py39). |
| 24 | + |
| 25 | +### Run MultiQC with the plugin |
| 26 | + |
| 27 | +```bash |
| 28 | +multiqc /path/to/xenium/data |
| 29 | +``` |
| 30 | + |
| 31 | +## Architecture |
| 32 | + |
| 33 | +The plugin uses MultiQC's hook system (v1) to extend functionality: |
| 34 | + |
| 35 | +- **`xenium_extra_execution_start`**: Called at startup to register search patterns for `transcripts.parquet`, `cells.parquet`, and `cell_feature_matrix.h5` files, and increase file size limit to 5GB. |
| 36 | + |
| 37 | +- **`extend_xenium_module`**: Called after the core Xenium module runs, receives the module instance and adds extra sections/data. |
| 38 | + |
| 39 | +All plugin code is in `multiqc_xenium_extra/xenium_extra.py`. The extension function: |
| 40 | + |
| 41 | +1. Parses parquet files using polars and H5 files using scanpy |
| 42 | +2. Merges computed metrics (cell area, nucleus area) into the module's `data_by_sample` dict |
| 43 | +3. Adds new general stats columns via `xenium_module.genstat_headers` |
| 44 | +4. Adds report sections via `xenium_module.add_section()` |
| 45 | + |
| 46 | +## Key Dependencies |
| 47 | + |
| 48 | +- **polars**: For efficient parquet file parsing |
| 49 | +- **scanpy**: For H5 matrix analysis |
| 50 | +- **scipy**: For statistical computations (KDE, distributions) |
| 51 | + |
| 52 | +## Gene Categories |
| 53 | + |
| 54 | +The plugin categorizes features by prefix: |
| 55 | + |
| 56 | +- `Custom_` → Custom |
| 57 | +- `NegControlProbe_` → Negative Control Probe |
| 58 | +- `NegControlCodeword_` → Negative Control Codeword |
| 59 | +- `GenomicControlProbe_` → Genomic Control Probe |
| 60 | +- `UnassignedCodeword_` → Unassigned Codeword |
| 61 | +- Default → Pre-designed |
0 commit comments