scverse / scverse/spatialdata

Method to validate the relationship between elements

Open
#218 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
394
Forks
95
Avg merge
4d 3h
Merged PRs (30d)
7

Description

I discussed this with @melonora today. Relevant also to @timtreis and @sagar87. CC @giovp

I would add a method to check the consistency of the table and the elements. This function would not throw errors, but check relationships are missing/invalid.
This is useful because sometimes we catch bugs only downstream (when trying to plot or aggregate something).

Not sure when we should call this method, maybe after the constructor, after reading and before saving. Or just let the user call it. The name could be validate_data_relationships().

Things that would be checked:

  • The regions in table.uns['spatialdata_attrs']['region'] are present in the sdata object.
  • The column with name table.uns['spatialdata_attrs']['region_key'] exists
  • The values of the rows in the column table.uns['spatialdata_attrs']['region_key'] are exactly the one in table.uns['spatialdata_attrs']['region'].
  • The column with name table.uns['spatialdata_attrs']['instance_key'] exists
  • The values of the rows in the column table.uns['spatialdata_attrs']['instance_key'] correspond to the value in the index of the corresponding regions. This check is done in napari_spatialdata when creating a shapes layer and or a labels layer. For instance this warning is given when some of the labels values and the table instance_key values don't match:
2023-04-05 15:12:39.751 | WARNING  | napari_spatialdata.interactive:_find_annotation_for_labels:435 - 11050/11051 labels not annotated: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86}
  • In a points object, the column with name INSTANCE_KEY exists.
  • In a points object, the values of the INSTANCE_KEY column actually refer to real regions. I have just realized that there may be a bug around this, I discuss this in this issue: https://github.com/scverse/spatialdata/issues/217

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the relationship checks listed in this issue and the related discussion in issue 217, including the napari_spatialdata validation reference. The completed work should define the validation method and its invocation strategy, then cover the listed table, region, instance-key, and points-object consistency checks without throwing errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.