Skip to content

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

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

Merged
merged 7 commits into from
Feb 10, 2025
Merged
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
3 changes: 3 additions & 0 deletions src/spatialdata_io/_constants/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ class XeniumKeys(ModeEnum):

# specs keys
ANALYSIS_SW_VERSION = "analysis_sw_version"
# spec which contains xeniumranger version whenever xeniumranger is used to resegment the data; the new, resegmented data
# needs to be parsed by considering the xeniumranger version
XENIUM_RANGER = "xenium_ranger"

# zarr file with labels file and cell summary keys
CELLS_ZARR = "cells.zarr.zip"
Expand Down
12 changes: 11 additions & 1 deletion src/spatialdata_io/readers/xenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,17 @@ 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 (e.g. 3.0.1.1) to resegment data from previous versions (e.g. xenium-1.6.0.7), a new dict is added to
# `specs`, named 'xenium_ranger', which contains the key 'version' and whose value specifies the version of xeniumranger used to
# resegment the data (e.g. 'xenium-3.0.1.1').
# When parsing the outs/ folder from the resegmented data, this version (rather than the original 'analysis_sw_version') is used
# whenever a code branch is dependent on the data version
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