Skip to content

Commit d148311

Browse files
committed
Merge branch 'main' into xenium-labels-dask
2 parents 0c80218 + 5f829f5 commit d148311

14 files changed

Lines changed: 836 additions & 252 deletions

File tree

.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
# -------

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ node_modules/
3636
.code-workspace
3737

3838
# test datasets (e.g. Xenium ones)
39+
# symlinks
40+
data
41+
# data folder
3942
data/
4043
tests/data
44+
uv.lock

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ default_stages:
77
minimum_pre_commit_version: 2.16.0
88
repos:
99
- repo: https://github.com/rbubley/mirrors-prettier
10-
rev: v3.6.2
10+
rev: v3.7.4
1111
hooks:
1212
- id: prettier
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.14.1
14+
rev: v0.14.10
1515
hooks:
1616
- id: ruff
1717
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
1818
- id: ruff-format
1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.18.2
20+
rev: v1.19.1
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: [numpy, types-PyYAML]

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies = [
3636
"readfcs",
3737
"tifffile>=2023.8.12",
3838
"ome-types",
39+
"xmltodict",
3940
]
4041

4142
[project.optional-dependencies]
@@ -59,6 +60,8 @@ doc = [
5960
test = [
6061
"pytest",
6162
"pytest-cov",
63+
# https://github.com/scverse/spatialdata-io/issues/334
64+
"pyarrow!=22"
6265
]
6366
# this will be used by readthedocs and will make pip also look for pre-releases, generally installing the latest available version
6467
# update: readthedocs doens't seem to try to install pre-releases even if when trying to install the pre optional-dependency. For

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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class SeqfishKeys(ModeEnum):
6868
TIFF_FILE = ".tiff"
6969
GEOJSON_FILE = ".geojson"
7070
# file identifiers
71-
ROI = "Roi"
7271
TRANSCRIPT_COORDINATES = "TranscriptList"
7372
DAPI = "DAPI"
7473
COUNTS_FILE = "CellxGene"
@@ -78,6 +77,7 @@ class SeqfishKeys(ModeEnum):
7877
# transcripts
7978
TRANSCRIPTS_X = "x"
8079
TRANSCRIPTS_Y = "y"
80+
TRANSCRIPTS_Z = "z"
8181
FEATURE_KEY = "name"
8282
INSTANCE_KEY_POINTS = "cell"
8383
# cells
@@ -88,8 +88,6 @@ class SeqfishKeys(ModeEnum):
8888
SPATIAL_KEY = "spatial"
8989
REGION_KEY = "region"
9090
INSTANCE_KEY_TABLE = "instance_id"
91-
SCALEFEFACTOR_X = "PhysicalSizeX"
92-
SCALEFEFACTOR_Y = "PhysicalSizeY"
9391

9492

9593
@unique
@@ -356,11 +354,16 @@ class VisiumHDKeys(ModeEnum):
356354
BIN_PREFIX = "square_"
357355
MICROSCOPE_IMAGE = "microscope_image"
358356
BINNED_OUTPUTS = "binned_outputs"
357+
SEGMENTATION_OUTPUTS = "segmented_outputs"
359358

360359
# counts and locations files
361360
FILTERED_COUNTS_FILE = "filtered_feature_bc_matrix.h5"
362361
RAW_COUNTS_FILE = "raw_feature_bc_matrix.h5"
363362
TISSUE_POSITIONS_FILE = "tissue_positions.parquet"
363+
BARCODE_MAPPINGS_FILE = "barcode_mappings.parquet"
364+
FILTERED_CELL_COUNTS_FILE = "filtered_feature_cell_matrix.h5"
365+
CELL_SEGMENTATION_GEOJSON_PATH = "cell_segmentations.geojson"
366+
NUCLEUS_SEGMENTATION_GEOJSON_PATH = "nucleus_segmentations.geojson"
364367

365368
# images
366369
IMAGE_HIRES_FILE = "tissue_hires_image.png"
@@ -402,3 +405,7 @@ class VisiumHDKeys(ModeEnum):
402405
MICROSCOPE_COLROW_TO_SPOT_COLROW = ("microscope_colrow_to_spot_colrow",)
403406
SPOT_COLROW_TO_MICROSCOPE_COLROW = ("spot_colrow_to_microscope_colrow",)
404407
FILE_FORMAT = "file_format"
408+
409+
# Cell Segmentation keys
410+
CELL_SEG_KEY_HD = "cell_segmentations"
411+
NUCLEUS_SEG_KEY_HD = "nucleus_segmentations"

src/spatialdata_io/readers/_utils/_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path
55
from typing import TYPE_CHECKING, Any, Union
66

7+
from anndata import AnnData
78
from anndata.io import read_text
89
from h5py import File
910
from ome_types import from_tiff

src/spatialdata_io/readers/cosmx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,4 @@ def cosmx(
289289
# logg.warning(f"FOV `{str(fov)}` does not exist, skipping it.")
290290
# continue
291291

292-
return SpatialData(images=images, labels=labels, points=points, table=table)
292+
return SpatialData(images=images, labels=labels, points=points, tables={"table": table})

0 commit comments

Comments
 (0)