Skip to main content

napari-colocalization logo

napari-colocalization

License MIT PyPI Python Version tests codecov napari hub npe2

⚠️ Under construction - pre-alpha. APIs, UI, and outputs may change without notice. Not recommended for production analysis yet; use at your own risk and please report rough edges via the issue tracker.

Interactive intensity-colocalization analysis for napari. Pick two channels (or one multi-channel image), optionally restrict the analysis to a region drawn as shapes or labels, choose your metric, and get a results table plus an intensity-vs-intensity density plot.

napari-colocalization widget

Features

  • Five colocalization metrics, spanning both families: three of correlation — Pearson (PCC), Spearman rank (SRCC) and Li's Intensity Correlation Quotient (ICQ) — and two of co-occurrence — Manders' overlap coefficient with split coefficients (r, k1, k2) and Manders' thresholded coefficients tM1/tM2.
  • Pairwise or all-to-all mode: analyse two grayscale layers, or every channel pair within a single multi-channel layer.
  • 2D and 3D support natively (no time-series for now).
  • Region-restricted analysis via a Shapes or Labels layer - each non-zero region is reported on its own row.
  • Manders thresholds: choose Costes auto (orthogonal-regression bisection, matched to Fiji Coloc 2), a per-channel auto-threshold (Otsu, Li, Triangle, Yen, Mean, IsoData → thresholded tM1/tM2), or Manual.
  • Per-Z-slice mode: analyse each plane of a stack separately (one row per slice), à la JACoP B's "consider Z slices separately".
  • Interactive results: in-widget table, density plot of the selected row, multi-row selection that highlights all matching shapes/labels in the viewer, and an optional fixed-axes cytofluorogram for comparable plots.
  • Diagnostics tab: single-pair diagnostic plots - Costes randomization significance test (observed PCC vs a scrambled null, with p-value/z-score), Van Steensel cross-correlation function (CCF), and Li intensity correlation analysis (ICA).
  • Object-based tab: compare segmented objects (from Labels layers or by thresholding) - centre-particle coincidence and object overlap per object, with centroid Points and nearest-neighbour Vectors drawn into the viewer.
  • Outputs to the viewer: add the colocalized-pixel mask (selected row) as a Labels layer, or a block-scrambled example as an Image layer.
  • CSV export of the current table, plus figure export of the density plot (PNG / PDF / SVG / TIFF, configurable size and DPI).

Installation

pip install napari-colocalization

If napari isn't already installed, install both at once:

pip install "napari-colocalization[all]"

For the latest development version:

pip install git+https://github.com/DBI-INFRA/napari-colocalization.git

Quick start

  1. Launch napari.

  2. Load sample data: File → Open Sample → napari-colocalization → Colocalization sample (2D). A 3D synthetic sample and CBS006RBM (a two-channel benchmark image from the Colocalization Benchmark Source) are also provided.

    Open Sample menu

  3. Open the widget: Plugins → Colocalization Analysis. Two image layers channel_a and channel_b are auto-selected for pairwise mode.

  4. Click Run. The results table populates with a single row (the whole image), and the density plot below shows the intensity pairs with the metric values overlaid.

napari-colocalization widget

  1. (Optional) Add a Shapes layer, draw a few rectangles or polygons, set Region to Shapes and pick the layer. Re-run - the table now has one row per shape, and clicking a row highlights the matching shape in the viewer.

napari-colocalization widget

See docs/usage.md for the full walkthrough.

Diagnostics

The Diagnostics tab runs single-pair diagnostic plots that go beyond a single number per region: the Costes randomization significance test (the observed PCC against a block-scrambled null, with a p-value and z-score), the Van Steensel cross-correlation function, and Li's intensity correlation analysis.

Diagnostics tab - Costes randomization

Object-based analysis

The Object-based tab compares segmented objects between the two channels: centre-particle coincidence (does an object's centroid fall inside an object of the other channel?) and object overlap, with one row per object. Objects come from existing Labels layers or by thresholding, and the detected centroids and nearest-neighbour links are drawn back into the viewer as Points and Vectors.

Object-based tab - coincidence and overlap

Documentation

  • Usage guide - every control in the widget, in order.
  • Metrics - what PCC, SRCC, ICQ, the overlap coefficient and Manders (tM1/tM2) mean, co-occurrence versus correlation, and how the Costes auto-threshold works.
  • Python API - calling the pure-compute layer (pearson, spearman, li_icq, manders, overlap, costes_threshold, costes_regression, analyse_pairwise, analyse_all_to_all) from scripts or notebooks.

Related projects

  • Coloc 2 - the reference ImageJ colocalization plugin; this plugin follows it in spirit, and the Costes auto-threshold here is matched to its implementation.
  • JACoP - "Just Another Colocalization Plugin" (Bolte & Cordelières, 2006); the inspiration for the diagnostics (Van Steensel CCF, Li ICA, Costes randomization) and the object-based analysis.
  • ijp-jacop-b - the BIOP fork of JACoP; inspired the per-channel auto-thresholds, per-Z-slice mode and the layers written back to the viewer.
  • scikit-image colocalization metrics: the underlying implementations of PCC and Manders.

Contributing

Contributions are welcome. Run the test suite with:

pip install -e . --group dev
python -m pytest tests/ -v

Pre-commit hooks (ruff lint + format, napari-plugin-checks) ship with the repo:

pre-commit install
pre-commit run --all-files

Please keep test coverage at or above the current level when submitting a PR.

License

Distributed under the terms of the MIT licence; napari-colocalization is free and open-source software.

Issues

Found a bug or have a feature request? Please open an issue.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

napari_colocalization-0.1.7.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

napari_colocalization-0.1.7-py3-none-any.whl (47.5 kB view details)

Uploaded Python 3

File details

Details for the file napari_colocalization-0.1.7.tar.gz.

File metadata

  • Download URL: napari_colocalization-0.1.7.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for napari_colocalization-0.1.7.tar.gz
Algorithm Hash digest
SHA256 99ade3a0a5c346d55305151bb8090878a5a6e4d678aa5152fe780f3d2a5faef3
MD5 86d238e0c8260ea653d40f95384ea7e0
BLAKE2b-256 d82d8397df72eca7f6925c9ad88e56aca30a1f0f067851fa258016c1962b3c53

See more details on using hashes here.

Provenance

The following attestation bundles were made for napari_colocalization-0.1.7.tar.gz:

Publisher: test_and_deploy.yml on DBI-INFRA/napari-colocalization

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file napari_colocalization-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_colocalization-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9addb68031358a44a970887df3b851559cd4d7aa07ad4da786a27a26ed82e79e
MD5 657b00a7dfcec528b0b070a5cb26ca42
BLAKE2b-256 b29b597ff47e63e846d2dd9f2cedff01c6e2d8b20c70d8f3e3a8b7a719f356d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for napari_colocalization-0.1.7-py3-none-any.whl:

Publisher: test_and_deploy.yml on DBI-INFRA/napari-colocalization

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page