Skip to content

Reading segmented data with Visium_HD (spaceranger>4) #310

@ddiez

Description

@ddiez

The newest version (>4) of spaceranger supports nuclei/cell segmentation of VisiumHD data. I wonder if there are official on going plans to give support to this new feature?

I am trying to get this data into spatialdata object but having some difficulties. This is how far I have come.

I can read the files with the nuclei and cell level segmentation:

sdata_hm["HM_nucleus_segmentation"] = io.geojson("data/HM/outs/segmented_outputs/nucleus_segmentations.geojson", coordinate_system="HM")
sdata_hm["HM_cell_segmentation"] = io.geojson("data/HM/outs/segmented_outputs/cell_segmentations.geojson", coordinate_system="HM")
sdata_hm

SpatialData object
├── Images
│     ├── 'HM_hires_image': DataArray[cyx] (3, 5057, 6000)
│     └── 'HM_lowres_image': DataArray[cyx] (3, 506, 600)
├── Shapes
│     ├── 'HM_cell_segmentation': GeoDataFrame shape: (69604, 1) (2D shapes)
│     ├── 'HM_nucleus_segmentation': GeoDataFrame shape: (69604, 1) (2D shapes)
│     └── 'HM_square_016um': GeoDataFrame shape: (48206, 1) (2D shapes)
└── Tables
      └── 'square_016um': AnnData (48206, 18085)
with coordinate systems:
    ▸ 'HM', with elements:
        HM_hires_image (Images), HM_lowres_image (Images), HM_cell_segmentation (Shapes), HM_nucleus_segmentation (Shapes), HM_square_016um (Shapes)
    ▸ 'HM_downscaled_hires', with elements:
        HM_hires_image (Images), HM_square_016um (Shapes)
    ▸ 'HM_downscaled_lowres', with elements:
        HM_lowres_image (Images), HM_square_016um (Shapes)

I can read and assign the AnnData table.

adata = sc.read_10x_h5("data/HM/outs/segmented_outputs/filtered_feature_cell_matrix.h5", gex_only=False)
adata.var_names_make_unique()
sdata_hm["cell_bins"] = adata
sdata_hm

SpatialData object, with associated Zarr store: [/media/diez/Biodev/projects/yamanaka-kidney/output/sdata_hm.zarr](https://vscode-remote+ssh-002dremote-002btower.vscode-resource.vscode-cdn.net/media/diez/Biodev/projects/yamanaka-kidney/output/sdata_hm.zarr)
├── Images
│     ├── 'HM_hires_image': DataArray[cyx] (3, 5057, 6000)
│     └── 'HM_lowres_image': DataArray[cyx] (3, 506, 600)
├── Shapes
│     ├── 'HM_cell_segmentation': GeoDataFrame shape: (69604, 1) (2D shapes)
│     ├── 'HM_nucleus_segmentation': GeoDataFrame shape: (69604, 1) (2D shapes)
│     └── 'HM_square_016um': GeoDataFrame shape: (48206, 1) (2D shapes)
└── Tables
      ├── 'cell_bins': AnnData (69601, 18085)
      └── 'square_016um': AnnData (48206, 18085)
with coordinate systems:
    ▸ 'HM', with elements:
        HM_hires_image (Images), HM_lowres_image (Images), HM_cell_segmentation (Shapes), HM_nucleus_segmentation (Shapes), HM_square_016um (Shapes)
    ▸ 'HM_downscaled_hires', with elements:
        HM_hires_image (Images), HM_square_016um (Shapes)
    ▸ 'HM_downscaled_lowres', with elements:
        HM_lowres_image (Images), HM_square_016um (Shapes)

With this set up I can visualize the shapes for the nuclei and cells. I can also select a ROI and visualize it and everything looks OK. But I cannot plot the gene expression. This is likely because I did not pass the AnnData through TableModel.parse. However, in order to do so I need to add additional data, one comming from VisiumHDKeys.TISSUE_POSITIONS_FILE that is tissue_positions.parquet and it is located in the spatial folder for the binned_outputs. However this file is missing in the segmented_outputs. I need to think about it because I still have gaps in my knowledge of the spatialdata framework but perhaps this makes sense since the cell shapes are irregular.

If no one is working on this I would like to help getting this supported in spatialdata although I would need some hints on what it is missing at the moment. Thanks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions