Debugged spatialdata writer with refactored shapes - #28
Merged
Conversation
EliHei2
added a commit
that referenced
this pull request
Jun 1, 2026
Adds a focused export feature on top of main that turns
segger_segmentation.parquet into downstream artifacts.
10x Xenium Explorer (default, `--format xenium`) follows 10x's current
`xeniumranger import-segmentation` workflow rather than hand-writing a
cells.zarr bundle:
- `--xenium-mode transcript_assignment`: Baysor-style segmentation.csv
(transcript_id/cell/is_noise) + segmentation_polygons.json viz polygons
- `--xenium-mode geojson`: cell polygon.geojson (objectType="cell")
- `--xenium-mode both` (default): all of the above
and prints the exact `xeniumranger import-segmentation` command to run.
Other formats: `merged` (transcripts joined with assignments), `anndata`
(cell x gene), and `spatialdata` (Zarr for scverse/SOPA, optional extra).
Cell polygons use our multi-core Delaunay boundary generation (boundary.py),
never convex hulls; degenerate (<3 vertex) cells are dropped to avoid
crashing Xenium Explorer.
SpatialData output uses the up-to-date latest-spatialdata writer (dask points
path, init_from_elements with fallback, pre-release _accessor workaround,
separate cell/nucleus shape elements) debugged by Enrico Bazzacco (PR #28).
spatialdata/spatialdata-io/sopa are optional extras; the base install stays
light via lazy imports.
Ported the proven export modules from the b450 dev branch and added a new,
smaller xenium_import.py for the import-segmentation path. transcript_id and
micron coordinates are recovered from the source bundle's transcripts.parquet
by joining on row_index (assigned before quality filtering, so the positional
join is exact).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
EliHei2
added a commit
that referenced
this pull request
Jun 1, 2026
Debugged spatialdata writer with refactored shapes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main issues identified during debugging relate to the initialization of the
SpatialDataobject with dictionaries and to writing. I also fixed cases in boundary generation with convex hull/delaunay where an ID has three or more points but the corresponding coordinates do not actually form a valid polygon (points coincide).I slightly refactored the shapes element creation by separating concerns: one helper function for input boundaries, called separately for cell and nucleus boundaries, and one for generated boundaries, called iteratively for cells and fragments.