https://github.com/saeyslab/harpy
Single-cell spatial omics analysis that makes you happy!
https://github.com/saeyslab/harpy
analysis-framework bioinformatics hpc machine-learning microscopy napari-plugin spatial
Last synced: 14 days ago
JSON representation
Single-cell spatial omics analysis that makes you happy!
- Host: GitHub
- URL: https://github.com/saeyslab/harpy
- Owner: saeyslab
- License: other
- Created: 2024-02-26T11:30:00.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-24T19:11:32.000Z (2 months ago)
- Last Synced: 2026-02-24T23:43:33.891Z (2 months ago)
- Topics: analysis-framework, bioinformatics, hpc, machine-learning, microscopy, napari-plugin, spatial
- Language: Python
- Homepage: https://harpy.readthedocs.io/en/latest/
- Size: 812 MB
- Stars: 52
- Watchers: 4
- Forks: 6
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
Single-cell spatial omics analysis that makes you happy.
[](https://pypi.org/project/harpy-analysis)
[](https://github.com/saeyslab/harpy/actions/workflows/release.yaml)
[](https://github.com/saeyslab/harpy/actions/)
[](https://github.com/saeyslab/harpy/actions/)
[](https://results.pre-commit.ci/latest/github/saeyslab/harpy/main)
[](https://harpy.readthedocs.io/en/latest/)
[](https://codecov.io/gh/saeyslab/harpy)
[](https://pepy.tech/project/harpy-analysis)
[](./LICENSE)

[](https://zenodo.org/badge/latestdoi/763481288)
[](https://doi.org/10.1093/bioinformatics/btag122)
Documentation
Β·
Quick Start
Β·
Tutorials
Β·
napari-harpy
Β·
Harpy Vitessce
> π« **If you find Harpy useful, please give us a [β](https://github.com/saeyslab/harpy)!** It helps others discover the project and supports continued development.
## Why Harpy?
Harpy is a spatial omics analysis library for spatial transcriptomics and proteomics. Within the [`scverse`](https://scverse.org/) stack, it bridges [`SpatialData`](https://spatialdata.scverse.org/) and downstream analysis tools such as [`AnnData`](https://anndata.readthedocs.io/), [`Scanpy`](https://scanpy.readthedocs.io/), and [`Squidpy`](https://squidpy.readthedocs.io/). It provides scalable, image- and geometry-aware computation to transform raw spatial data into analysis-ready representations, with a strong emphasis on interoperability and large-scale workflows.
In practice, Harpy offers fast, out-of-core image preprocessing, tiled segmentation, along with efficient aggregation workflows to generate `AnnData` tables and compute per-cell features from images, segmentation masks, and transcript coordinates. It also supports deep feature extraction, pixel- and cell-level clustering, and the construction of single-cell representations from highly multiplexed images.
- **Multi-platform support** for spatial transcriptomics and proteomics data.
- **Interoperable outputs** built on [SpatialData](https://github.com/scverse/spatialdata).
- **Scales to (very) large images**: tiled workflows with [Dask](https://www.dask.org/); optional GPU acceleration with [CuPy](https://cupy.dev/) and [PyTorch](https://pytorch.org/).
- **Scalable computational building blocks** for segmentation, feature extraction, clustering, and spatial analysis.
## Installation
```bash
pip install harpy-analysis
```
**With extras**
```bash
pip install "harpy-analysis[extra]"
```
`[extra]` installs optional dependencies for:
- Segmentation: `cellpose`
- OpenCV support: `opencv-python-headless`
- FlowSOM Clustering: `flowsom`
- Notebook workflows: `ipywidgets`, `tqdm`, `bokeh`, `textalloc`, `joypy`, `supervenn`, `nbconvert`, `ipython`
- CLI workflows: `hydra-core`
**With extras and napari**
```bash
pip install "harpy-analysis[extra,napari]"
```
`[napari]` adds:
- `napari[all]`
- `napari-spatialdata`
**Only for developers.** Clone this repository locally, install the `.[dev]` instead of the `[extra]` dependencies and read the [contribution guide](https://harpy.readthedocs.io/en/latest/contributing.html).
```bash
# Clone repository from GitHub
uv venv --python=3.12 # create venv, set python version (>=3.11)
source .venv/bin/activate # activate the virtual environment
uv pip install -e '.[dev]' # editable install with dev tooling
python -c 'import harpy; print(harpy.__version__)' # check if the package is installed
# make changes
python -m pytest # run the tests
```
It is possible to install Harpy using Anaconda although we recommend [uv](https://github.com/astral-sh/uv), see the [installation guide](./docs/installation.md).
## Quickstart
See the short, runnable [guide](https://harpy.readthedocs.io/en/latest/quickstart.html).
## π§ Tutorials and Guides
Explore how to use Harpy for segmentation, shallow and deep feature extraction, clustering, and spatial analysis of gigapixel-scale multiplexed data with these step-by-step notebooks:
- **π Basic Usage of Harpy**
Learn how to read in data, perform **tiled segmentation** using [**Cellpose**](https://github.com/MouseLand/cellpose) and [**Dask-CUDA**](https://docs.rapids.ai/api/dask-cuda/stable/), extract features, perform QC and analyze results downstream with `Scanpy` and `Squidpy`.
π [Tutorial image based transcriptomics, Human Ovarian Cancer, Xenium 10x Genomics](https://harpy.readthedocs.io/en/latest/tutorials/general/Harpy_xenium_transcriptomics_subset.html)
π [Tutorial proteomics, MACSima](https://harpy.readthedocs.io/en/latest/tutorials/general/Harpy_feature_calculation.html)
- **π§ Technology-specific advice**
Learn which technologies Harpy supports. π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/general/techno_specific.html)
- **π§© Pixel and Cell Clustering**
Learn how to perform unsupervised pixel- and cell-level clustering using `Harpy` together with [**FlowSOM**](https://github.com/saeyslab/FlowSOM_Python). π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/general/FlowSOM_for_pixel_and_cell_clustering.html)
- **βοΈ Cell Segmentation**
Explore segmentation workflows in `Harpy` using different tools:
- With [**Instanseg**](https://github.com/instanseg/instanseg) π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/general/Harpy_instanseg.html)
- With [**Cellpose**](https://github.com/MouseLand/cellpose) π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/general/Harpy_feature_calculation.html)
π‘ Want us to add support for another segmentation method?
π [Open an issue](https://github.com/saeyslab/harpy/issues) and let us know!
- **π§ͺ Single-cell representations from highly multiplexed images and downstream use with [PyTorch](https://pytorch.org/)**
Learn how single-cell representations can be generated from highly multiplexed images. These representations can then be used downstream to train classifiers in PyTorch. π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/general/generate_single_cell_representations.html)
- **π§ Deep Feature Extraction**
Discover how `Harpy` enables fast, scalable extraction of deep, cell-level features from multiplex imaging data with the [**KRONOS**](https://github.com/mahmoodlab/KRONOS) foundation model for proteomics. π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/general/Featurize_with_kronos.html)
π‘ Want us to add support for another deep feature extraction method?
π [Open an issue](https://github.com/saeyslab/harpy/issues) and let us know!
- **π¬ Shallow Feature Extraction**
Learn to extract shallow featuresβsuch as **mean**, **median**, and **standard deviation** of intensitiesβfrom multiplex imaging data with `Harpy`. π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/advanced/Harpy_aggregate_rasters.html)
- **𧬠Spatial Transcriptomics**
Learn how to analyze spatial transcriptomics data with `Harpy`.
π [Tutorial (Mouse Liver, Resolve Molecular Cartography)](https://harpy.readthedocs.io/en/latest/tutorials/advanced/Harpy_transcriptomics.html)
π [Tutorial (Human Ovarian Cancer, Xenium 10x Genomics)](https://harpy.readthedocs.io/en/latest/tutorials/advanced/Harpy_transcriptomics_xenium.html)
---
- **π Multiple samples and coordinate systems**
Learn how to work with multiple samples, intrinsic and micron coordinates. π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/advanced/coordinate_systems.html)
---
- **π Rasterize and vectorize labels and shapes**
Learn how to convert a segmentation mask (array) into its vectorized form, and segmentation boundaries (polygons) into their rasterized equivalents. This conversion is useful, for example, when integrating annotations (e.g., from [QuPath](https://qupath.github.io/)) into downstream spatial omics analysis.π [Tutorial](https://harpy.readthedocs.io/en/latest/tutorials/advanced/Rasterize_and_vectorize.html)
---
π For a complete list of tutorials, visit the [**Harpy documentation**](https://harpy.readthedocs.io/en/latest/tutorials).
## Computational benchmark
Explore the benchmark performance of **Harpy** on a large MACSima tonsil proteomics dataset. π [Results](https://harpy.readthedocs.io/en/latest/tutorials/general/benchmark.html)
## Contributing
See the [contribution guide](https://harpy.readthedocs.io/en/latest/contributing.html) for info on how to contribute to Harpy.
## Citation
If you use Harpy in your work, please cite:
> Benjamin Rombaut, Arne Defauw, Frank Vernaillen, Julien Mortier, Evelien Van Hamme, Sofie Van Gassen, Ruth Seurinck, Yvan Saeys. _Scalable analysis of whole slide spatial proteomics with Harpy_. _Bioinformatics_ (2026), btag122. [https://doi.org/10.1093/bioinformatics/btag122](https://doi.org/10.1093/bioinformatics/btag122)
If you use Harpy for spatial transcriptomics analysis, please cite:
> Lotte Pollaris, Bavo Vanneste, Benjamin Rombaut, Arne Defauw, Frank Vernaillen, Julien Mortier, Wout Vanhenden, Liesbet Martens, Tinne Thone, Jean-Francois Hastir, Anna Bujko, Wouter Saelens, Jean-Christophe Marine, Hilde Nelissen, Evelien Van Hamme, Ruth Seurinck, Charlotte L. Scott, Martin Guilliams, Yvan Saeys. _SPArrOW: a flexible, interactive and scalable pipeline for spatial transcriptomics analysis_. [https://doi.org/10.1101/2024.07.04.601829](https://doi.org/10.1101/2024.07.04.601829)
## License
Check the [license](https://github.com/saeyslab/harpy/blob/main/LICENSE). Harpy is free for academic usage.
For commercial usage, please contact Saeyslab.
## Issues
If you encounter any problems, please [file an issue] along with a detailed description.
[Cookiecutter]: https://github.com/audreyr/cookiecutter
[BSD-3]: http://opensource.org/licenses/BSD-3-Clause
[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin
[file an issue]: https://github.com/saeyslab/harpy/issues
[napari]: https://github.com/napari/napari
[tox]: https://tox.readthedocs.io/en/latest/
[pip]: https://pypi.org/project/pip/
[PyPI]: https://pypi.org/