Skip to content

spatiomic 0.10.1: map cluster colors by label, support unassigned pixels - #29

Merged
maltekuehl merged 1 commit into
mainfrom
release/0.10.1
Oct 22, 2026
Merged

maltekuehl merged 1 commit into
mainfrom
release/0.10.1

Conversation

@maltekuehl

Copy link
Copy Markdown
Contributor

Release 0.10.1. Release notes: docs/source/release-notes/0.10.1.md.

Bug fixes

  • Cluster colors match the colormap. so.plot.cluster_image, save_cluster_image, cluster_legend, cluster_selection, save_cluster_selection, som_clusters and the colorbars of cluster_scatter and connectivity_graph now show each cluster in the color with the same index in the colormap. Before, the colormap was scaled to the range of labels present in each image, so images that lacked the highest cluster labels, or that contained unassigned pixels, showed clusters in the colors of other clusters. Colormap names and continuous colormaps, e.g., colormap="flag" for segmentation masks with many labels, are still spread from label 0 to the highest label.
  • Unassigned pixels are supported. Pixels without a nearest SOM node, i.e., all-zero pixels with the cosine metric and constant pixels with the correlation metric, are labelled -1 by so.dimension.som().label since 0.10.0. They are now handled throughout:
    • Cluster plots show them transparent (black in cluster_selection), and cluster_location does not show them as a cluster.
    • so.spatial.vicinity_composition counts them neither as a cluster nor as a neighbor, and its permutation test keeps them in place.
    • so.spatial.autocorrelation does not analyse them as a cluster, and so.spatial.local_heteroskedasticity assigns them to no cluster.
    • so.spatial.local_autocorrelation, which operates on the label values, raises a ValueError for them.
  • Integer labels of any type are accepted. vicinity_composition, autocorrelation and local_autocorrelation rejected the int32 labels returned by so.dimension.som().label since 0.10.0. Invalid clustered images now raise a TypeError or ValueError instead of an AssertionError.

Docs

Reruns the full_example, scverse, segment and spatial tutorials with 0.10.x.

Testing

  • ruff, ruff format, mypy -p spatiomic, bandit: clean
  • CPU suite: 230 passed
  • New test/plot/test_cluster_image.py checks the exact colors drawn and saved, including unassigned pixels, missing labels and continuous colormaps; spatial tests check that results with unassigned pixels equal those with an extra cluster that is then dropped.
  • Docs build cleanly.
  • The mypy pre-commit hook now runs in the project environment (uv run mypy); before, it used whichever mypy was on the PATH.

🤖 Generated with Claude Code

- Show each cluster in the color with the same index in a ListedColormap
  in cluster_image, save_cluster_image, cluster_legend, cluster_selection,
  save_cluster_selection, som_clusters and the cluster_scatter and
  connectivity_graph colorbars, instead of scaling the colormap to the
  labels present in each image. Colormap names and continuous colormaps
  are still spread from label 0 to the highest label.
- Support unassigned pixels (-1, no nearest SOM node under the cosine or
  correlation metric): transparent in cluster plots, skipped by
  cluster_location, vicinity_composition and autocorrelation, assigned to
  no cluster by local_heteroskedasticity, rejected by
  local_autocorrelation. vicinity_composition permutations keep them in
  place.
- Accept integer labels of any dtype (int32 labels from Som.label were
  rejected) and raise TypeError/ValueError instead of AssertionError.
- Run the mypy pre-commit hook in the project environment (uv run) instead
  of whichever mypy is on the PATH.
- Rerun the full_example, scverse, segment and spatial tutorials.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@maltekuehl
maltekuehl merged commit 5138d5e into main Oct 22, 2026
3 checks passed
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.94%. Comparing base (877cf4f) to head (810bd6e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
spatiomic/spatial/_local_heteroskedasticity.py 16.66% 5 Missing ⚠️
spatiomic/spatial/_local_autocorrelation.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
+ Coverage   78.73%   78.94%   +0.21%     
==========================================
  Files          54       55       +1     
  Lines        1876     1890      +14     
==========================================
+ Hits         1477     1492      +15     
+ Misses        399      398       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants