Skip to content

Conversation

@ArneDefauw
Copy link
Contributor

@ArneDefauw ArneDefauw commented Dec 17, 2024

PR related to scverse/spatialdata-io#211 and provides complimentary changes to spatialdata.rasterize_bins.

See unit test https://github.com/ArneDefauw/spatialdata/blob/5c3edee642bad1eaedbddf2097430315b964bb1a/tests/core/operations/test_rasterize_bins.py#L36

And more in particular https://github.com/ArneDefauw/spatialdata/blob/5c3edee642bad1eaedbddf2097430315b964bb1a/tests/core/operations/test_rasterize_bins.py#L80

Note that even if the table is annotated by a labels layer created by spatialdata.rasterize_bins, we want to be able to run the raterize_bins function, but now withreturn_region_as_labels=True, see https://github.com/ArneDefauw/spatialdata/blob/5c3edee642bad1eaedbddf2097430315b964bb1a/tests/core/operations/test_rasterize_bins.py#L111.
There is a use case for this, e.g. you have leiden cluster ID's, and you want a 'snappy' way to also visualize gene expression levels in napari-spatialdata, see example below:

Screenshot 2024-12-17 at 13 30 42

@codecov
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 94.04762% with 5 lines in your changes missing coverage. Please review.

Project coverage is 91.79%. Comparing base (7bce868) to head (8cd2304).
Report is 56 commits behind head on main.

Files with missing lines Patch % Lines
src/spatialdata/models/_utils.py 64.28% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #811      +/-   ##
==========================================
- Coverage   91.80%   91.79%   -0.01%     
==========================================
  Files          45       45              
  Lines        7064     7118      +54     
==========================================
+ Hits         6485     6534      +49     
- Misses        579      584       +5     
Files with missing lines Coverage Δ
src/spatialdata/__init__.py 96.29% <100.00%> (ø)
src/spatialdata/_core/operations/rasterize_bins.py 93.07% <100.00%> (+3.18%) ⬆️
src/spatialdata/transformations/_utils.py 91.92% <100.00%> (ø)
src/spatialdata/models/_utils.py 88.33% <64.28%> (-2.09%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaMarconato
Copy link
Member

I reviewed the PR and it's ready to merge! Thanks again @ArneDefauw.
The main change that I made is that I do not modify the instance_key column, rather I add a new one. I also added an helper function to quickly make the table annotate the labels (using this new column).

Finally, I added tests to cover the case in which instance_key is of string dtype.

@LucaMarconato LucaMarconato merged commit cf0445b into scverse:main Jan 2, 2025
8 checks passed
@LucaMarconato LucaMarconato changed the title Visium hd rasterize bins labels rasterize_bins() can now produce a labels element Jan 20, 2025
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