spatial-omics-dataset-loading
Summary
Load bundled spatial transcriptomics datasets into AnnData objects using squidpy.datasets, preparing them for downstream spatial analysis workflows. This skill establishes the foundational data structure that integrates spatial coordinates, gene expression, and optional microscopy images.
When to use
You have a spatial transcriptomics experiment (e.g., Slide-seq v2, MERFISH, or other spatial molecular assay) and need to initialize an AnnData object with spatial metadata, expression matrices, and coordinate information before applying spatial statistics, feature extraction, or visualization methods like squidpy.gr.sepal or interactive tissue exploration.
When NOT to use
- Your spatial data is already loaded into an AnnData object with verified spatial coordinates — use this skill only for initial data ingestion from bundled sources.
- You are working with custom or private spatial datasets not available in squidpy.datasets — use alternative loaders (e.g., manual .h5ad import, custom parsing) instead.
- Your data is in a non-AnnData format (e.g., raw coordinate/expression CSV files) — preprocess to AnnData structure first or use format-specific loaders.
Inputs
- Dataset identifier string (e.g., 'slideseqv2', 'merfish')
- Optional sample/tissue specification parameter
Outputs
- AnnData object with expression matrix (.X)
- Spatial coordinates in .obsm['spatial'] or similar key
- Cell/spot metadata in .obs
- Gene metadata in .var
- Optionally, tissue image data in .uns
How to apply
Call squidpy.datasets with the target dataset name (e.g., 'slideseqv2' or 'merfish') to download and instantiate a bundled spatial dataset. The function returns an AnnData object with expression data in .X, cell/spot metadata in .obs, gene metadata in .var, spatial coordinates typically stored in .obsm (e.g., 'spatial' for 2D coordinates), and optionally tissue images in .uns. Verify that the returned object contains the expected slots: non-empty .X (expression matrix), .obs with coordinate or metadata columns, .obsm with spatial key, and .uns with image or microscopy data if applicable. This initialization step is critical because downstream methods like squidpy.gr.sepal expect the spatial coordinate key and standard AnnData structure.
Related tools
- squidpy (Provides squidpy.datasets function to load bundled spatial transcriptomics datasets and downstream spatial analysis APIs) — https://github.com/scverse/squidpy
- anndata (Defines the AnnData object structure that stores expression, spatial coordinates, and metadata)
- scanpy (Provides foundational single-cell analysis methods and data structure conventions inherited by squidpy)
Examples
import squidpy as sq; adata = sq.datasets.slideseqv2()
Evaluation signals
- Returned object is an AnnData instance with non-empty .X (expression matrix) of expected dimensions (n_obs × n_vars)
- Spatial coordinates are present in .obsm with key 'spatial' or similar, with shape (n_obs, 2) for 2D or (n_obs, 3) for 3D
- Cell/spot metadata (.obs) contains expected columns (e.g., 'cell_type', 'batch', or assay-specific fields) with correct dtypes
- Gene metadata (.var) contains expected columns (e.g., 'gene_names', 'highly_variable') matching n_vars
- Tissue image or microscopy data is present in .uns if applicable to the dataset (e.g., 'images', 'hires_image')
Limitations
- squidpy.datasets only provides a curated set of bundled examples; users with custom or unpublished datasets must implement custom loaders.
- Coordinate systems and units (e.g., pixel coordinates vs. physical microns) vary by dataset and assay; users must verify coordinate interpretation before spatial analysis.
- Large datasets may require significant memory; users should check available RAM and consider data subsetting strategies if needed.
Evidence
- [other] Load a bundled spatial dataset using squidpy.datasets (slideseqv2 or merfish) into an AnnData object.: "Load a bundled spatial dataset using squidpy.datasets (slideseqv2 or merfish) into an AnnData object."
- [intro] Squidpy builds on scanpy and anndata, providing streamlined APIs for feature extraction, spatial statistics, and interactive exploration of tissue sections together with microscopy images: "It builds on scanpy and anndata providing streamlined APIs for feature extraction, spatial statistics, and interactive exploration of tissue sections together with microscopy images"
- [intro] Squidpy is the scverse toolkit for scalable analysis and visualization of spatial molecular data.: "Squidpy is the scverse toolkit for scalable analysis and visualization of spatial molecular data."
1---2name: spatial-omics-dataset-loading3description: Use when you have a spatial transcriptomics experiment (e.4license: CC-BY-4.05---67# spatial-omics-dataset-loading89## Summary1011Load bundled spatial transcriptomics datasets into AnnData objects using squidpy.datasets, preparing them for downstream spatial analysis workflows. This skill establishes the foundational data structure that integrates spatial coordinates, gene expression, and optional microscopy images.1213## When to use1415You have a spatial transcriptomics experiment (e.g., Slide-seq v2, MERFISH, or other spatial molecular assay) and need to initialize an AnnData object with spatial metadata, expression matrices, and coordinate information before applying spatial statistics, feature extraction, or visualization methods like squidpy.gr.sepal or interactive tissue exploration.1617## When NOT to use1819- Your spatial data is already loaded into an AnnData object with verified spatial coordinates — use this skill only for initial data ingestion from bundled sources.20- You are working with custom or private spatial datasets not available in squidpy.datasets — use alternative loaders (e.g., manual .h5ad import, custom parsing) instead.21- Your data is in a non-AnnData format (e.g., raw coordinate/expression CSV files) — preprocess to AnnData structure first or use format-specific loaders.2223## Inputs2425- Dataset identifier string (e.g., 'slideseqv2', 'merfish')26- Optional sample/tissue specification parameter2728## Outputs2930- AnnData object with expression matrix (.X)31- Spatial coordinates in .obsm['spatial'] or similar key32- Cell/spot metadata in .obs33- Gene metadata in .var34- Optionally, tissue image data in .uns3536## How to apply3738Call squidpy.datasets with the target dataset name (e.g., 'slideseqv2' or 'merfish') to download and instantiate a bundled spatial dataset. The function returns an AnnData object with expression data in .X, cell/spot metadata in .obs, gene metadata in .var, spatial coordinates typically stored in .obsm (e.g., 'spatial' for 2D coordinates), and optionally tissue images in .uns. Verify that the returned object contains the expected slots: non-empty .X (expression matrix), .obs with coordinate or metadata columns, .obsm with spatial key, and .uns with image or microscopy data if applicable. This initialization step is critical because downstream methods like squidpy.gr.sepal expect the spatial coordinate key and standard AnnData structure.3940## Related tools4142- **squidpy** (Provides squidpy.datasets function to load bundled spatial transcriptomics datasets and downstream spatial analysis APIs) — https://github.com/scverse/squidpy43- **anndata** (Defines the AnnData object structure that stores expression, spatial coordinates, and metadata)44- **scanpy** (Provides foundational single-cell analysis methods and data structure conventions inherited by squidpy)4546## Examples4748```49import squidpy as sq; adata = sq.datasets.slideseqv2()50```5152## Evaluation signals5354- Returned object is an AnnData instance with non-empty .X (expression matrix) of expected dimensions (n_obs × n_vars)55- Spatial coordinates are present in .obsm with key 'spatial' or similar, with shape (n_obs, 2) for 2D or (n_obs, 3) for 3D56- Cell/spot metadata (.obs) contains expected columns (e.g., 'cell_type', 'batch', or assay-specific fields) with correct dtypes57- Gene metadata (.var) contains expected columns (e.g., 'gene_names', 'highly_variable') matching n_vars58- Tissue image or microscopy data is present in .uns if applicable to the dataset (e.g., 'images', 'hires_image')5960## Limitations6162- squidpy.datasets only provides a curated set of bundled examples; users with custom or unpublished datasets must implement custom loaders.63- Coordinate systems and units (e.g., pixel coordinates vs. physical microns) vary by dataset and assay; users must verify coordinate interpretation before spatial analysis.64- Large datasets may require significant memory; users should check available RAM and consider data subsetting strategies if needed.6566## Evidence6768- [other] Load a bundled spatial dataset using squidpy.datasets (slideseqv2 or merfish) into an AnnData object.: "Load a bundled spatial dataset using squidpy.datasets (slideseqv2 or merfish) into an AnnData object."69- [intro] Squidpy builds on scanpy and anndata, providing streamlined APIs for feature extraction, spatial statistics, and interactive exploration of tissue sections together with microscopy images: "It builds on scanpy and anndata providing streamlined APIs for feature extraction, spatial statistics, and interactive exploration of tissue sections together with microscopy images"70- [intro] Squidpy is the scverse toolkit for scalable analysis and visualization of spatial molecular data.: "Squidpy is the scverse toolkit for scalable analysis and visualization of spatial molecular data."