Input/Output#

To read the data from a specific technology (e.g., Xenium, MERSCOPE, …), you can use any of the spatialdata-io readers.

spatialdata.read_zarr(store, selection=None, on_bad_files=BadFileHandleMethod.ERROR)[source]#

Read a SpatialData dataset from a zarr store (on-disk or remote).

This is the underlying reader used by spatialdata.SpatialData.read(). Compared to that method, it also accepts an already-open zarr.Group and lets you skip corrupted or invalid elements instead of failing (see on_bad_files). It cannot repair the consolidated metadata of the store; for that, read from a path with spatialdata.SpatialData.read() and reconsolidate_metadata=True.

Parameters:
store str | Path | UPath | Group

Path, URL, or zarr.Group to the zarr store (on-disk or remote).

selection None | tuple[str] (default: None)

List of elements to read from the zarr store (images, labels, points, shapes, tables). If None, all elements are read.

on_bad_files Literal[BadFileHandleMethod.ERROR, BadFileHandleMethod.WARN] (default: BadFileHandleMethod.ERROR)

Specifies what to do upon encountering a bad file, e.g. corrupted, invalid or missing files. Allowed values are :

  • ’error’, raise an exception when a bad file is encountered. Reading aborts immediately with an error.

  • ’warn’, raise a warning when a bad file is encountered and skip that file. A SpatialData object is returned containing only elements that could be read. Failures can only be determined from the warnings.

Return type:

SpatialData

Returns:

A SpatialData object.

See also

spatialdata.SpatialData.read

Convenience wrapper that reads from a path and can reconsolidate the metadata.

spatialdata.get_dask_backing_files(element)[source]#
spatialdata.get_dask_backing_files(element: SpatialData) → list[str]
spatialdata.get_dask_backing_files(element: DataArray) → list[str]
spatialdata.get_dask_backing_files(element: DataTree) → list[str]
spatialdata.get_dask_backing_files(element: DataFrame) → list[str]
spatialdata.get_dask_backing_files(element: AnnData | GeoDataFrame) → list[str]
spatialdata.get_dask_backing_files(element: AnnData | GeoDataFrame) → list[str]

Get the backing files that appear in the Dask computational graph of an element/any element of a SpatialData object.

Parameters:
element SpatialData | SpatialElement | AnnData

The element to get the backing files from.

Return type:

list[str]

Returns:

List of backing files.

Notes

It is possible for lazy objects to be constructed from multiple files.