Simple solution but not high priority. I need to implement a function that subsets an `sdata` object by passing a list of names of elements. For instance ``` SpatialData object with: ├── Images │ ├── 'morphology_focus': MultiscaleSpatialImage[cyx] (1, 25778, 35416), (1, 12889, 17708), (1, 6444, 8854), (1, 3222, 4427), (1, 1611, 2213) │ └── 'morphology_mip': MultiscaleSpatialImage[cyx] (1, 25778, 35416), (1, 12889, 17708), (1, 6444, 8854), (1, 3222, 4427), (1, 1611, 2213) ├── Points │ └── 'transcripts': DataFrame with shape: (42638083, 9) (3D points) ├── Shapes │ ├── 'cell_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes) │ ├── 'cell_circles': GeoDataFrame shape: (167780, 2) (2D shapes) │ └── 'nucleus_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes) └── Table └── AnnData object with n_obs × n_vars = 167780 × 313 obs: 'cell_id', 'transcript_counts', 'control_probe_counts', 'control_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'region', 'dataset', 'celltype_major', 'celltype_minor' var: 'gene_ids', 'feature_types', 'genome' uns: 'spatialdata_attrs' obsm: 'spatial': AnnData (167780, 313) with coordinate systems: ▸ 'aligned', with elements: morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes) ▸ 'global', with elements: morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes) ``` I want to be able to make a query like: ``` sdata.query.elements(['morphology_focus', 'cell_circles'], filter_table=True) ``` Notes: * names are unique so we don't need to say that the first is an image and the second is a shapes * `filter_table` is `True` by default, as in other parts of the code. @timtreis do you also need this code/do you already have it? For the moment I am doing this subsets manually.
Activity
timtreis commentedon Apr 4, 2023
Yeah, I have that -> https://github.com/scverse/spatialdata-plot/blob/549a6ebf84ae9abd49dc1a0bba7a5dff42e4604a/src/spatialdata_plot/pp/basic.py#L71
Was supposed to go upstream anyway
LucaMarconato commentedon Apr 4, 2023
Very nice! After the paper we can coordinate on this to move the functionality upstream.
timtreis commentedon Apr 5, 2023
Shall I open a PR?
LucaMarconato commentedon Apr 5, 2023
Yes please do it (at any time).
LucaMarconato commentedon Feb 22, 2024
Closed with #426.