scverse / spatialdata

An open and interoperable data framework for spatial omics data
https://spatialdata.scverse.org/
BSD 3-Clause "New" or "Revised" License
174 stars 34 forks source link

add static set annotation #510

Closed melonora closed 1 month ago

melonora commented 1 month ago

Added function for setting the annotation target of a table that is outside a SpatialData object. This function has a slightly different name from its counterpart. This because this is specific to setting the annotation target.

I did think about a single dispatch method, but in that case the counterpart wouldn't be specific to a spatialdata object.

The function for dealing with tables outside a spatialdata object is useful when performing a SQL like join operation that results in a table changing the annotation targets from 2 to 1 target. I did not allow for directly just specifying regions as anyways we have to do a validation which would require checking the unique elements in the column.

Instance_id is not included as this is typically not changing. If it does change the user should just parse the table again and specify all the metadata.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 90.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 92.57%. Comparing base (270d81f) to head (b6614f6).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #510 +/- ## ========================================== - Coverage 92.57% 92.57% -0.01% ========================================== Files 43 43 Lines 5928 5938 +10 ========================================== + Hits 5488 5497 +9 - Misses 440 441 +1 ``` | [Files](https://app.codecov.io/gh/scverse/spatialdata/pull/510?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse) | Coverage Δ | | |---|---|---| | [src/spatialdata/\_core/spatialdata.py](https://app.codecov.io/gh/scverse/spatialdata/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scverse#diff-c3JjL3NwYXRpYWxkYXRhL19jb3JlL3NwYXRpYWxkYXRhLnB5) | `92.21% <90.00%> (-0.04%)` | :arrow_down: |