-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type and storage of instance_key
issues
#158
Comments
I wrongly thought that TODO:
|
Yeah there was this code in
EDIT: |
but this is in fact true! see what I wrote above
so no need to fix |
From this formulation I understand that if |
got it, you mean that |
yes, we can replace it with must (well, MUST). Yes for concatenation the problem is when the |
true, especially in
I prefer allowing
We got some bugs with this (the type was string in one object and int in the other), I think we should be clear that the type should match. |
I’m not sure I’m following here. @giovp, do you mean that for SpatialData we require that even if a table annotates a single region (I.e., ‘region’ is a string), we need a valid ‘region_key’ column? I’m guessing the rationale is that it makes the concatenation at easier in some cases since the resulting table would need a ‘region_key’ column. I think we will still have to do some parsing of the ‘region_key’ column during concatenation, even if we require a region_key column for all tables. This is because the region_key value might not be the same for all columns being annotated. Or did you mean that when ‘region’ is a string, ‘region_key’ MUST be None? If that’s the case, then I agree we should update the tables spec to match that. We can still proceed with that here though without waiting for the dust to settle on the tables spec. |
+1
I am open to allowing references to regions that are not present. However, if that’s the case, we should have a simple method to filter a SpatialData.table to only include rows that annotate regions in the object.
I agree that we should validate the region/instance_key values when parsing the models. |
ok, I'll try to summarise the solutions below:
|
I would also have a method to actually filter the data to make them match (we need two parameters, like Regarding regions that are not annotated by the table, this case is super common. Especially since the table can only annotated limited elements, so most of the elements will not be annotated. Examples: the "anatomical" (polygon/shapes) element in merfish, or the nuclei regions in xenium (the table annotates |
Unrelated to the above but related to spatialdata/spatialdata/_core/models.py Line 464 in 4fb3433
|
that's a very good point, completely missed that, should be very flexible |
I'll update this PR to reflect this. #159 All the io code and the |
@giovp and @LucaMarconato , thanks for looking into this. I like/agree with the following from above:
I agree with @LucaMarconato about the methods to filter tables for elements in the containing I also agree that we need to allow elements that are not in the table (but I think @giovp you are already on board with that) |
So even if the consensus was to use I propose to change the readers in CC @melonora |
This is to keep track of issues that might arise on the relationship between
instance_key
and the indexes of regions.Motivation
The link between a table and it's region object is specified by the tuple
("region", "region_key")
saved intable.uns["spatialdata_attrs"]
. The types are the followingregion: Union[str, Sequence[str]]
. It can contain a single region id or a sequence of region idsregion_key: Optional[str]
. In case of a single region_id, then it can be NoneTo link the single region instance, e.g. the cell, an additional key is passed:
instance_key: Sequence[str, float, int]
Problems
instance_key
matching the type of the index/region in the respective element? e.g. for labels,, it should just beint32
orint64
, whereas for shapes, it could bestr
ornumeric
.spatialdata_attrs
another thing to consider is that the
instance_key
can be just he index in aShapes
element, but it can never be an index intable.obs
, because we can only havestr
and numeric indexes in anndata. This is also something we should be clearer about.The text was updated successfully, but these errors were encountered: