Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pyxa_v1_io/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Stellaromics Pyxa (v1 output files)

The `xsmall` subset of the [Stellaromics/demo](https://huggingface.co/datasets/Stellaromics/demo) dataset on the
Hugging Face Hub (BSD 3-Clause): a 100 × 100 × 100 µm cube (187 cells, ~23k transcripts) with the four Pyxa output
files and a DAPI mosaic (multiscale OME-Zarr), ~8 MB in total. It is the same subset used in the spatialdata-io CI
tests for the experimental `pyxa` reader.

`download.py` fetches it into `data/`, and `to_zarr.py` converts it with `spatialdata_io.experimental.pyxa()`. The
full demo region (`small/`, ~290 MB) has the same layout.
32 changes: 32 additions & 0 deletions pyxa_v1_io/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
##
import os
import subprocess
import zipfile
from pathlib import Path

# from https://huggingface.co/datasets/Stellaromics/demo (BSD 3-Clause)
# xsmall/: a 100 x 100 x 100 um cube cropped from the full demo region (small/), ~8 MB

BASE_URL = "https://huggingface.co/datasets/Stellaromics/demo/resolve/main/xsmall"
FILES = [
"cell_assigned_gene_v1.csv",
"cell_by_gene_v1.csv",
"cell_metadata_v1.csv",
"segmentation_geometries_v1.parquet",
"mosaic_3d.ome.zarr.zip",
]

data_dir = Path(__file__).resolve().parent / "data"
os.makedirs(data_dir, exist_ok=True)

##
# download the data
for filename in FILES:
command = f"curl -L -C - -o {data_dir / filename} {BASE_URL}/{filename}"
subprocess.run(command, shell=True, check=True)

##
# unzip the DAPI mosaic (a zipped OME-Zarr store containing mosaic_3d.ome.zarr/)
with zipfile.ZipFile(data_dir / "mosaic_3d.ome.zarr.zip") as zf:
zf.extractall(data_dir)
os.remove(data_dir / "mosaic_3d.ome.zarr.zip")
40 changes: 40 additions & 0 deletions pyxa_v1_io/to_zarr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# /// script
# requires-python = ">=3.12"
# dependencies = [
# # the pyxa reader is pending review in scverse/spatialdata-io
# "spatialdata-io @ git+https://github.com/ckmah/spatialdata-io.git@pyxa-reader",
# ]
# ///
##
from spatialdata_io.experimental import pyxa
import spatialdata as sd

##
from pathlib import Path
import shutil

##
path = Path().resolve()
# luca's workaround for pycharm
if not str(path).endswith("pyxa_v1_io"):
path /= "pyxa_v1_io"
assert path.exists()

path_read = path / "data"
path_write = path / "data.zarr"

##
print("parsing the data... ", end="")
sdata = pyxa(path_read, image_path=path_read / "mosaic_3d.ome.zarr")
print("done")

##
print("writing the data... ", end="")
if path_write.exists():
shutil.rmtree(path_write)
sdata.write(path_write)
print("done")

##
sdata = sd.SpatialData.read(path_write)
print(sdata)