Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves spatialdata_io.xenium() capability to read in xeniumranger v3.0.1.1 resegemented data #244

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/spatialdata_io/_constants/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class XeniumKeys(ModeEnum):

# specs keys
ANALYSIS_SW_VERSION = "analysis_sw_version"
# spec which contains xeniumranger version (after resegment is run from xenium-3.0.1.1)
XENIUM_RANGER = "xenium_ranger"

# zarr file with labels file and cell summary keys
CELLS_ZARR = "cells.zarr.zip"
Expand Down
11 changes: 10 additions & 1 deletion src/spatialdata_io/readers/xenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,16 @@ def _parse_version_of_xenium_analyzer(
specs: dict[str, Any],
hide_warning: bool = True,
) -> packaging.version.Version | None:
string = specs[XeniumKeys.ANALYSIS_SW_VERSION]

# After using xeniumranger 3.0.1.1 to resegment data from xenium-1.6.0.7, a new dict is added to `specs`, named 'xenium_ranger',
# which contains the key 'version' and it's value pair 'xenium-3.0.1.1' for the resegmented,
# which contains a new 'version' key and value is added in specs, using this version (rather than the original 'analysis_sw_version'),
# corrects branching and parsing when using xenium() on the xeniumranger resegmented /outs/ folder path
if specs.get(XeniumKeys.XENIUM_RANGER):
string = specs[XeniumKeys.XENIUM_RANGER]["version"]
else:
string = specs[XeniumKeys.ANALYSIS_SW_VERSION]

pattern = r"^(?:x|X)enium-(\d+\.\d+\.\d+(\.\d+-\d+)?)"

result = re.search(pattern, string)
Expand Down
Loading