spatialrefinery.xenium_to_spatialdata_zip#
- spatialrefinery.xenium_to_spatialdata_zip(dataset_path, output_path, output_name=None, include_aligned_image=True, create_spots=True, spot_sizes=None, overlap=0.0, values='transcripts', n_jobs=1, overwrite=False, keep_zarr=True, max_spots_per_chunk=50000)#
Convert Xenium data to SpatialData zarr and create a zip archive.
This function is a wrapper around
xenium_to_spatialdatathat additionally creates a zip archive of the zarr directory for easier transfer.- Parameters:
dataset_path (
str|Path) – Path to the Xenium dataset directory containing raw files.output_path (
str|Path) – Path to the directory where files will be saved.output_name (
str|None(default:None)) – Name for the output files. If None, uses the dataset directory name.include_aligned_image (
bool(default:True)) – Whether to include aligned H&E image if available. Default is True.create_spots (
bool(default:True)) – Whether to create pseudo-spots. Default is True.spot_sizes (
list|None(default:None)) – List of spot sizes in micrometers. Default is None. Spots are only created when bothcreate_spotsis True andspot_sizesis a non-empty list – the default combination (create_spots=True,spot_sizes=None) creates no spots.overlap (
float|None(default:0.0)) – Fractional overlap between adjacent hexagonal spots, forwarded tocreate_pseudo_spots. Default is 0.0 (no overlap).values (
str(default:'transcripts')) – Which SpatialData element to aggregate into spots:"transcripts"or"cell_boundaries". Default is"transcripts".n_jobs (
int(default:1)) – Number of workers for parallel processing. Default is 1.overwrite (
bool(default:False)) – Whether to overwrite existing files. Default is False.keep_zarr (
bool(default:True)) – Whether to keep the unzipped zarr directory after creating zip. Default is True.max_spots_per_chunk (
int|None(default:50000)) – Retained for backwards compatibility and ignored; transcript aggregation is now streamed. Seecreate_pseudo_spots.
- Return type:
- Returns:
Path Path to the created zip file.
- Raises:
FileNotFoundError – If
dataset_pathdoes not contain anexperiment.xeniumfile (raised by the underlyingxenium_to_spatialdatacall).
Examples
>>> from spatialrefinery import xenium_to_spatialdata_zip >>> zip_path = xenium_to_spatialdata_zip( ... dataset_path="/path/to/xenium/data", ... output_path="/path/to/output", ... output_name="my_sample", ... keep_zarr=False, # Remove zarr directory after zipping ... )