A spatial omics interface for napari.
Project description
napari-harpy: a spatial omics interface for napari.
Built around SpatialData and Harpy for interactive exploration, feature extraction, and object classification.
napari-harpy is a napari plugin for viewing, exploring, and analyzing
SpatialData datasets. It includes its own viewer for loading and
browsing data inside napari, alongside feature extraction and interactive
object classification workflows.
Installation
Install from PyPI:
pip install napari-harpy
Quickstart
The quickest way to try the plugin is to create a small example SpatialData
object, write it to a temporary zarr store, read it back as an on-disk dataset,
and launch the Harpy napari interface with Interactive.
import tempfile
from pathlib import Path
from spatialdata import read_zarr
from napari_harpy import Interactive
from napari_harpy.datasets import blobs_multi_region
zarr_path = Path(tempfile.mkdtemp()) / "blobs_multi_region.zarr"
sdata = blobs_multi_region()
sdata.write(zarr_path)
sdata = read_zarr(zarr_path)
Interactive(sdata)
This opens napari with the Harpy widgets docked and the
blobs_multi_region dataset available in the shared viewer state.
The current repository contains three working widgets:
ViewerFeature ExtractionObject Classification
Today the plugin supports:
- loading and viewing
SpatialDatathrough the Harpy viewer widget - selecting a labels element, optional image, compatible coordinate system, and
linked table from the shared loaded
SpatialData - calculating intensity and morphology features through Harpy
- writing feature matrices into the selected
AnnDatatable linked to the labels element, as.obsm[feature_key], with companion metadata in.uns["feature_matrices"][feature_key] - interactive manual annotation of instances in labels elements
- background
RandomForestClassifierretraining on the selected feature matrix stored in.obsm[feature_key]of theAnnDatatable linked to the labels element - live prediction updates and labels recoloring
- explicit write-back of in-memory table state to zarr
- explicit reload of on-disk table state back into memory
- multi-sample workflows through multi-region tables and explicit labels/image/coordinate-system matching
- headless feature extraction and classifier application for scripted or batch processing
Example napari-harpy session:
Headless and Multi-Sample Workflows
For scripted or batch processing, use the public napari_harpy.headless module.
It can apply an exported classifier to an existing feature matrix, or compute
the required features before applying the classifier.
The headless APIs accept one labels element or a sequence of labels elements. For multi-sample data, pass matching labels, image, and coordinate-system sequences so Harpy can build or apply a shared table-level feature matrix across the selected samples.
from spatialdata import read_zarr
from napari_harpy import headless
sdata = read_zarr("experiment.zarr")
result = headless.apply_classifier_with_feature_extraction_from_path(
sdata,
"classifier.harpy-classifier.joblib",
table_name="table_multi",
labels_name=["sample_1_labels", "sample_2_labels"],
coordinate_system=["sample_1", "sample_2"],
image_name=["sample_1_image", "sample_2_image"],
)
Local development
Create the development environment:
./create_env.sh
Then launch napari:
source .venv/bin/activate
napari
Open the widgets from the napari plugin menu:
Plugins -> napari-harpy -> ViewerPlugins -> napari-harpy -> Feature ExtractionPlugins -> napari-harpy -> Object Classification
Debug script
A small local debug script is available at
scripts/debug_widget.py.
It creates a temporary blobs_multi_region zarr store, loads it into napari,
and docks the Harpy widgets automatically.
This is useful for quickly reproducing widget behavior during development.
Run it with:
source .venv/bin/activate
python scripts/debug_widget.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file napari_harpy-0.0.5.tar.gz.
File metadata
- Download URL: napari_harpy-0.0.5.tar.gz
- Upload date:
- Size: 11.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3e09197b49ef062e545dde9303a3ebd0aacaa9015b60120d0d7825e8044a682
|
|
| MD5 |
1a0c5df83d252e367836a1fcd3457a32
|
|
| BLAKE2b-256 |
512af4f18838f3555ade217ed36243a7454273c2897765f02e265bfcd88ee88a
|
Provenance
The following attestation bundles were made for napari_harpy-0.0.5.tar.gz:
Publisher:
release.yaml on vibspatial/napari-harpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
napari_harpy-0.0.5.tar.gz -
Subject digest:
f3e09197b49ef062e545dde9303a3ebd0aacaa9015b60120d0d7825e8044a682 - Sigstore transparency entry: 1602919396
- Sigstore integration time:
-
Permalink:
vibspatial/napari-harpy@597858b34448bb1c94e73fdd233e41ec776d4a82 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/vibspatial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@597858b34448bb1c94e73fdd233e41ec776d4a82 -
Trigger Event:
release
-
Statement type:
File details
Details for the file napari_harpy-0.0.5-py3-none-any.whl.
File metadata
- Download URL: napari_harpy-0.0.5-py3-none-any.whl
- Upload date:
- Size: 178.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23b56f9e46bfd75e51ae8cf58af99d73a11d071cdfe7b83fa0abb6a1f73eca6b
|
|
| MD5 |
5bf0d0fc25c19d01c160eff21af745f4
|
|
| BLAKE2b-256 |
a03064df5898556fda765aa52c2b24657702efc848f94d96512dcb1f608b7d21
|
Provenance
The following attestation bundles were made for napari_harpy-0.0.5-py3-none-any.whl:
Publisher:
release.yaml on vibspatial/napari-harpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
napari_harpy-0.0.5-py3-none-any.whl -
Subject digest:
23b56f9e46bfd75e51ae8cf58af99d73a11d071cdfe7b83fa0abb6a1f73eca6b - Sigstore transparency entry: 1602919611
- Sigstore integration time:
-
Permalink:
vibspatial/napari-harpy@597858b34448bb1c94e73fdd233e41ec776d4a82 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/vibspatial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@597858b34448bb1c94e73fdd233e41ec776d4a82 -
Trigger Event:
release
-
Statement type: