Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SpatialData: data on disk

What it does

After stitching, each image is converted into a SpatialData store: one folder ({sample}.zarr) that holds the image, the cell outlines and the table of measurements together, aligned to each other.

Parameters

None directly. use_preprocessing decides where channel names come from: the marker sheet when the pipeline stitched the image, or the image’s own names when you give a stitched image.

How it works

SpatialData is a data format and Python library for spatial omics. A dataset is built from five kinds of element: images, labels (segmentation masks), points, shapes (polygons, such as cells) and tables (one row per cell, with its measurements). Each element carries a transformation into a shared coordinate system, so elements from different sources can be overlaid and queried together Marconato et al., 2024.

On disk it is a Zarr store, a folder built on the OME-NGFF image standard. Zarr stores arrays in chunks and at several resolutions, so a program loads only the chunks and the resolution it needs, and an image larger than memory can be read one piece at a time.

Six panels: the five element types stored as OME-NGFF Zarr, the Python library aligning and querying datasets, readers for several technologies, napari annotation, a PyTorch interface and ecosystem tools.

SpatialData’s design. (a) The storage format: tables, points, shapes, labels and images in Zarr. (b) The Python library: aligned datasets, spatial queries and aggregation. (c–f) Readers, annotation, deep learning and ecosystem tools, which this pipeline does not use. Reproduced from Marconato et al., 2024, CC BY 4.0.

The store is built up step by step:

  1. The stitched OME-TIFF is converted into {sample}.zarr.

  2. The marker names from the marker sheet are written onto the image’s channels. Stitching drops them; without this step channels would be called Channel:0:0 and so on.

  3. Later steps add the tissue outline, the patch grid, the projection, and finally the cell outlines and one table per segmentation method.

  4. On a TMA each core has its own store until the cores are merged into one store per slide, with every element renamed {core_id}__{name}.

  5. The finished store is copied to your results folder.

Images stay in pixels, and so do all areas and lengths; the pixel size stays in the stitched OME-TIFF.

Inputs and outputs. In: one stitched OME-TIFF per sample (or per TMA core). Out: {sample}.zarr (or {slide}_merged.zarr on a TMA) in your results folder. Its layout, and how to open it: The SpatialData store.

Similar tools

SpatialData came with the downstream half from nf-core/sopa, which is built on it. Sopa reads the image chunk by chunk, so the whole image never has to fit in memory Blampey et al., 2024.

Read more

Version used:

ModuleToolVersionContainerPaper
TO_SPATIALDATAsopa2.2.9community.wave.seqera.io/library/python_sopa:54a97bc5a187152d
SET_CHANNEL_NAMESsopa2.2.9community.wave.seqera.io/library/python_sopa:54a97bc5a187152d
WRITE_SEGMENTATIONSsopa2.3.0docker.io/josenimo/sopa:2.3.0-1Blampey et al. (2024)
MERGE_SPATIALDATAsopa2.2.9community.wave.seqera.io/library/python_sopa:54a97bc5a187152d
PUBLISH_SPATIALDATApublish_spatialdatanone (runs on the host)
References
  1. Marconato, L., Palla, G., Yamauchi, K. A., Virshup, I., Heidari, E., Treis, T., Vierdag, W.-M., Toth, M., Stockhaus, S., Shrestha, R. B., Rombaut, B., Pollaris, L., Lehner, L., Vöhringer, H., Kats, I., Saeys, Y., Saka, S. K., Huber, W., Gerstung, M., … Stegle, O. (2024). SpatialData: an open and universal data framework for spatial omics. Nature Methods, 22(1), 58–62. 10.1038/s41592-024-02212-x
  2. Blampey, Q., Mulder, K., Gardet, M., Christodoulidis, S., Dutertre, C.-A., André, F., Ginhoux, F., & Cournède, P.-H. (2024). Sopa: a technology-invariant pipeline for analyses of image-based spatial omics. Nature Communications, 15(1). 10.1038/s41467-024-48981-z