spatialdata_io.visium_hd

Contents

spatialdata_io.visium_hd#

spatialdata_io.visium_hd(path, dataset_id=None, filtered_counts_file=True, load_segmentations_only=None, load_nucleus_segmentations=False, bin_size=None, bins_as_squares=True, annotate_table_by_labels=False, fullres_image_file=None, load_all_images=False, var_names_make_unique=True, imread_kwargs=mappingproxy({}), image_models_kwargs=mappingproxy({}), anndata_kwargs=mappingproxy({}), gex_only=False)#

Read 10x Genomics Visium HD formatted dataset.

Parameters:
  • path (str | Path) – Path to directory containing the 10x Genomics Visium HD output.

  • dataset_id (str | None (default: None)) – Unique identifier of the dataset, used to name the elements of the SpatialData object. If None, it is inferred from the file name of the feature slice file.

  • filtered_counts_file (bool (default: True)) – It sets the value of counts_file to 'filtered_feature_bc_matrix.h5' (when True) or to 'raw_feature_bc_matrix.h5' (when False).

  • load_segmentations_only (bool | None (default: None)) – If True, only the segmented cell boundaries and their associated counts will be loaded. All binned data will be skipped. If False, only the binned data will be loaded (which is consistent with legacy behavior). If None (default), it will be equivalent to False, but a deprecation warning will be raised to inform users that in future releases the default value will be changed to True. To avoid the warning, explicitly set this parameter to False or True.

  • load_nucleus_segmentations (bool (default: False)) – If True and nucleus segmentation files are present, load nucleus segmentation polygons and the corresponding nucleus-filtered count table. The counts are aggregated from the 2 µm binned matrix using the provided barcode mappings so that only bins under segmented nuclei contribute to each cell’s counts. Requires all of: nucleus segmentation GeoJSON, barcode_mappings.parquet, and the 2 µm filtered_feature_bc_matrix.h5.

  • bin_size (int | list[int] | None (default: None)) – When specified, load the data of a specific bin size, or a list of bin sizes. By default, it loads all the available bin sizes.

  • bins_as_squares (bool (default: True)) – If True, the bins are represented as squares. If False, the bins are represented as circles. For a correct visualization one should use squares.

  • annotate_table_by_labels (bool (default: False)) – If True, the tables will annotate labels layers representing the bins, if False, the tables will annotate shapes layer.

  • fullres_image_file (str | Path | None (default: None)) – Path to the full-resolution image. By default the image is searched in the 'microscope_image' directory.

  • load_all_images (bool (default: False)) – If False, load only the full resolution, high resolution and low resolution images. If True, also the following images: 'cytassist_image.tiff'.

  • var_names_make_unique (bool (default: True)) – If True, call .var_names_make_unique() on each AnnData table.

  • imread_kwargs (Mapping[str, Any] (default: mappingproxy({}))) – Keyword arguments for imageio.imread().

  • image_models_kwargs (Mapping[str, Any] (default: mappingproxy({}))) – Keyword arguments for spatialdata.models.Image2DModel. The scale_factors key, when provided, overrides the scale factors used to downscale the full-resolution image (default: [2, 2, 2, 2]). The low-resolution images (i.e. “lowres”, “hires”, and “CytAssist”) ignore scale_factors and are always stored as single-scale images (xarray.DataArray).

  • anndata_kwargs (Mapping[str, Any] (default: mappingproxy({}))) – Keyword arguments for anndata.io.read_h5ad().

  • gex_only (bool (default: False)) – If True, only the gene expression (GEX) data will be loaded.

Return type:

SpatialData

Returns:

: SpatialData object for the Visium HD data.