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

error from minimalistic reading of xenium data #132

Closed
EliHei2 opened this issue Mar 29, 2024 · 4 comments
Closed

error from minimalistic reading of xenium data #132

EliHei2 opened this issue Mar 29, 2024 · 4 comments

Comments

@EliHei2
Copy link

EliHei2 commented Mar 29, 2024

Hola! just updated both spatialdata and spatialdata-io trying to read a generic xenium dataset with the following line, I get the error bellow:

sdata = spatialdata_io.xenium(
        'Xenium_V1_FFPE_Human_Breast_IDC', 
        morphology_mip=False, 
        morphology_focus=False, 
        cell_boundaries=False,
        cells_as_circles=False,
        cell_labels=False,
        nucleus_labels=False
    )
    if cell_labels_indices_mapping is not None:
UnboundLocalError: local variable 'cell_labels_indices_mapping' referenced before assignment
@LucaMarconato
Copy link
Member

Hola! Well spotted 🥸 Fixed with https://github.com/scverse/spatialdata-io/releases/tag/v0.1.2, which also adds the parameter aligned_images: bool, to skip some extra H&E or IF images sometimes present in more recent datasets.

@EliHei2
Copy link
Author

EliHei2 commented Apr 1, 2024

Thanks Luca! Sorry for opening again, there's another error still, which I can guess where's it from (i.e., not reading cell boundaries) but leave it here:

line 344, in _get_polygons
    assert index.equals(idx)
AssertionError

@LucaMarconato LucaMarconato reopened this Apr 1, 2024
@LucaMarconato
Copy link
Member

Got back to this today. I have tried to replicate with the same argument but that line doesn't give me an error. I think the bug is now solved.

If you encounter it please feel free to reopen; in such a case please detail a link to a public dataset that can be used to replicate the bug, and to the code used to call the xenium() function.

@asmitaL99
Copy link

Hi, I keep getting this error :

---------------------------------------------------------------------------TypeError Traceback (most recent call last)
Cell In[14], line 3 1 # Parse Xenium data 2 print("parsing the data... ", end="")----> 3 sdata = xenium( 4 path=str(path_read), 5 n_jobs=8, 6 cell_boundaries=True, 7 nucleus_boundaries=True, 8 morphology_focus=True, 9 ) 10 print("done")

File /opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/spatialdata_io/_utils.py:46, in deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs) 44 class_name = f.qualname 45 rename_kwargs(f.name, kwargs, aliases, class_name)---> 46 return f(*args, **kwargs)

File /opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/spatialdata_io/readers/xenium.py:334, in xenium(path, cells_boundaries, nucleus_boundaries, cells_as_circles, cells_labels, nucleus_labels, transcripts, morphology_mip, morphology_focus, aligned_images, cells_table, n_jobs, imread_kwargs, image_models_kwargs, labels_models_kwargs) 330 assert ( 331 "c_coords" not in image_models_kwargs 332 ), "The channel names for the morphology focus images are handled internally" 333 image_models_kwargs["c_coords"] = list(channel_names.values())--> 334 images["morphology_focus"] = _get_images( 335 morphology_focus_dir, 336 XeniumKeys.MORPHOLOGY_FOCUS_CHANNEL_IMAGE.format(0), 337 imread_kwargs, 338 image_models_kwargs, 339 ) 340 del image_models_kwargs["c_coords"] 341 logger.removeFilter(IgnoreSpecificMessage())

File /opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/spatialdata_io/readers/xenium.py:564, in _get_images(path, file, imread_kwargs, image_models_kwargs) 558 if "c_coords" in image_models_kwargs and "dummy" in image_models_kwargs["c_coords"]: 559 # Napari currently interprets 4 channel images as RGB; a series of PRs to fix this is almost ready but they will 560 # not be merged soon. 561 # Here, since the new data from the xenium analyzer version 2.0.0 gives 4-channel images that are not RGBA, 562 # let's add a dummy channel as a temporary workaround. 563 image = da.concatenate([image, da.zeros_like(image[0:1])], axis=0)--> 564 return Image2DModel.parse( 565 image, transformations={"global": Identity()}, dims=("c", "y", "x"), rgb=None, **image_models_kwargs 566 )

File /opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/spatialdata/models/models.py:189, in RasterSchema.parse(cls, data, dims, transformations, scale_factors, method, chunks, **kwargs) 183 raise ValueError( 184 f"Cannot transpose arrays to match dims: {dims}.", 185 "Try to reshape data or dims.", 186 ) from e 188 # finally convert to spatial image--> 189 data = to_spatial_image(array_like=data, dims=cls.dims.dims, **kwargs)
190 # parse transformations 191 _parse_transformations(data, transformations)

TypeError: to_spatial_image() got an unexpected keyword argument 'rgb'

when I try to run this command :

Parse Xenium data

print("parsing the data... ", end="")
sdata = xenium(
path=str(path_read),
n_jobs=8,
cell_boundaries=True,
nucleus_boundaries=True,
morphology_focus=True,
)
print("done")

Link to public dataset to reproduce this : I use the full bundle from that link:

https://www.10xgenomics.com/datasets/preview-data-ffpe-human-lung-cancer-with-xenium-multimodal-cell-segmentation-1-standard

lucas-diedrich pushed a commit to lucas-diedrich/spatialdata-io that referenced this issue Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants