Skip to content

When using TableModel.parse, region_key must be provided. #306

Closed

Description

@yedeer12

I want to use TableModel.parse to parse the whole anndata, I set region=None, region_key=None, instance_key=None. But there is an error says region_key must be provided. Could I combine the anndata and spatialdata without region and region_key?
image

image

Activity

  1. giovp commented on Jun 22, 2023

    @giovp
    Member

    hi @yedeer12 ,

    no you can't, spatialdata assumes that when a table it's present, it annotates a region element (shapes, labels).

    We are working toward building a converter for anndata to spatialdata for anndata that are already available. pinging @LLehner who is working on it.

  2. EliHei2 commented on Jun 27, 2023

    @EliHei2
    Collaborator

    Related to this, @giovp, if one plug in an anndata as the table using sd.TableModel.parse if the region_key column is not existing in the .obs the function does not return an error, while if one save the whole SpatialData object and try to reload it, they will receive the following error:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/e915i/.conda/envs/py39/lib/python3.9/site-packages/spatialdata/_io/io_zarr.py", line 85, in read_zarr
        sdata = SpatialData(
      File "/home/e915i/.conda/envs/py39/lib/python3.9/site-packages/spatialdata/_core/spatialdata.py", line 161, in __init__
        Table_s.validate(table)
      File "/home/e915i/.conda/envs/py39/lib/python3.9/site-packages/spatialdata/models/models.py", line 644, in validate
        raise ValueError(f"`{attr[self.REGION_KEY_KEY]}` not found in `adata.obs`.")
    ValueError: `None` not found in `adata.obs`.
    

    I used the defaults (hence region_key=None)

    I suggest either assert this in the TableModel.parse or write or drop the assert in read_zarr.

  3. LucaMarconato commented on Jun 28, 2023

    @LucaMarconato
    Member

    Thanks @EliHei2, I think we should assert it in TableModel.parse().

  4. LucaMarconato commented on Feb 22, 2024

    @LucaMarconato
    Member

    Now with #455, we support multiple tables and also tables that are not associated with any set of geometries (i.e. region_key not provided).

  5. linked a pull request that will close this issuemulti table support #455on Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions