Skip to content

Commit 55efc2c

Browse files
Merge pull request #328 from 10XGenomics/stephen/spaceranger4.0
Feat: Support for Visium HD cell segmentation in Space Ranger 4.0
2 parents 5ea8189 + 301650e commit 55efc2c

File tree

6 files changed

+668
-181
lines changed

6 files changed

+668
-181
lines changed

.github/workflows/prepare_test_data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
# the Visium HD dataset is licensed as CC BY 4.0, as shown here
5050
# https://www.10xgenomics.com/support/software/space-ranger/latest/resources/visium-hd-example-data
5151
52-
# 10x Genomics Visium HD 4.0.1 3' Mouse Brain
52+
# 10x Genomics Visium HD 4.0.1 3' Mouse Brain Chunk
5353
curl -O https://cf.10xgenomics.com/samples/spatial-exp/4.0.1/Visium_HD_Tiny_3prime_Dataset/Visium_HD_Tiny_3prime_Dataset_outs.zip
5454
5555
# -------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"joblib",
3333
"imagecodecs",
3434
"dask-image",
35-
"pyarrow",
35+
"pyarrow<22.0.0", # https://github.com/scverse/spatialdata-io/issues/334
3636
"readfcs",
3737
"tifffile>=2023.8.12",
3838
"ome-types",

src/spatialdata_io/__main__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,24 @@ def visium_wrapper(
412412
default=False,
413413
help="If true, annotates the table by labels. [default: False]",
414414
)
415+
@click.option(
416+
"--load-segmentations-only",
417+
default=None,
418+
help="If `True`, only the segmented cell boundaries and their associated counts will be loaded. All binned data will be skipped. [default: None, which will fall back to `False` with a deprecation warning]",
419+
)
420+
@click.option(
421+
"--load-nucleus-segmentations",
422+
type=bool,
423+
default=False,
424+
help="If `True` and nucleus segmentation files are present, load nucleus segmentation polygons and the corresponding nucleus-filtered count table. [default: False]",
425+
)
415426
def visium_hd_wrapper(
416427
input: str,
417428
output: str,
418429
dataset_id: str | None = None,
419430
filtered_counts_file: bool = True,
431+
load_segmentations_only: bool | None = None,
432+
load_nucleus_segmentations: bool = False,
420433
bin_size: int | list[int] | None = None,
421434
bins_as_squares: bool = True,
422435
fullres_image_file: str | Path | None = None,
@@ -428,6 +441,8 @@ def visium_hd_wrapper(
428441
path=input,
429442
dataset_id=dataset_id,
430443
filtered_counts_file=filtered_counts_file,
444+
load_segmentations_only=load_segmentations_only,
445+
load_nucleus_segmentations=load_nucleus_segmentations,
431446
bin_size=bin_size,
432447
bins_as_squares=bins_as_squares,
433448
fullres_image_file=fullres_image_file,

src/spatialdata_io/_constants/_constants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,16 @@ class VisiumHDKeys(ModeEnum):
356356
BIN_PREFIX = "square_"
357357
MICROSCOPE_IMAGE = "microscope_image"
358358
BINNED_OUTPUTS = "binned_outputs"
359+
SEGMENTATION_OUTPUTS = "segmented_outputs"
359360

360361
# counts and locations files
361362
FILTERED_COUNTS_FILE = "filtered_feature_bc_matrix.h5"
362363
RAW_COUNTS_FILE = "raw_feature_bc_matrix.h5"
363364
TISSUE_POSITIONS_FILE = "tissue_positions.parquet"
365+
BARCODE_MAPPINGS_FILE = "barcode_mappings.parquet"
366+
FILTERED_CELL_COUNTS_FILE = "filtered_feature_cell_matrix.h5"
367+
CELL_SEGMENTATION_GEOJSON_PATH = "cell_segmentations.geojson"
368+
NUCLEUS_SEGMENTATION_GEOJSON_PATH = "nucleus_segmentations.geojson"
364369

365370
# images
366371
IMAGE_HIRES_FILE = "tissue_hires_image.png"
@@ -402,3 +407,7 @@ class VisiumHDKeys(ModeEnum):
402407
MICROSCOPE_COLROW_TO_SPOT_COLROW = ("microscope_colrow_to_spot_colrow",)
403408
SPOT_COLROW_TO_MICROSCOPE_COLROW = ("spot_colrow_to_microscope_colrow",)
404409
FILE_FORMAT = "file_format"
410+
411+
# Cell Segmentation keys
412+
CELL_SEG_KEY_HD = "cell_segmentations"
413+
NUCLEUS_SEG_KEY_HD = "nucleus_segmentations"

0 commit comments

Comments
 (0)