spatialdata
spatialdata copied to clipboard
Drop `region` (`region_key` and `instance_key` are enough)
Motivation
The region metadata field was introduced at the storage format level to be able to tell which elements a table is annotating, without the need to examine the data in the table.
In memory the region metadata is redundant, as region can be computed on-the-fly looking at
adata = sdata.tables['my_table']
region_key = adata.uns['spatialdata_attrs']['region_key']
region = adata.obs[region_key].cat.categories
(the above assumes that the region_key column is categorical, which is already a requirement for certain plotting functions and operations (such as rasterize_bins())).
Dropping region will simplify the syntax when dealing with tables. For instance now when calling set_table_annotates_spatialelement(), the user needs to adjust the region metadata manually.
Plan
With this issue we propose (@melonora and I) to:
- [ ] drop the
regionmetadata in-memory - [ ] when writing, compute the metadata as above
- [ ] when reading, ignoring the
regionmetadata - [ ] provide a property computed as above for convenience (since the above code is verbose).