Skip to content

Commit

Permalink
Merge pull request #244 from Pancreas-Pratik/main
Browse files Browse the repository at this point in the history
resolves spatialdata_io.xenium() capability to read in xeniumranger v3.0.1.1 resegemented data
  • Loading branch information
LucaMarconato authored Feb 10, 2025
2 parents 3890c36 + 296d9a5 commit 46ba82b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/spatialdata_io/_constants/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,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

0 comments on commit 46ba82b

Please sign in to comment.