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 in Interactive when going through the tutorial #294

Closed
jefferyUstc opened this issue Jun 12, 2023 · 6 comments
Closed

Error in Interactive when going through the tutorial #294

jefferyUstc opened this issue Jun 12, 2023 · 6 comments

Comments

@jefferyUstc
Copy link

Hi, nice work of spatialdata to facilitate the integrtive analysis of multi-modal spatial omics.

I'm checking out the tutorial provided in the documentation and encountered an Error below:

Tutorial: Use landmark annotations to align multiple -omics layers, https://spatialdata.scverse.org/en/latest/tutorials/notebooks/notebooks/examples/alignment_using_landmarks.html#adding-landmark-annotations

After read in the visium and xenium data, I run the Interactive function to visualize the data:

Interactive([visium_sdata, xenium_sdata], points=False, shapes=False)
  • Error 1 occurs :
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[12], line 1
----> 1 Interactive([visium_sdata, xenium_sdata], points=False, shapes=False)

TypeError: Interactive.__init__() got an unexpected keyword argument 'points'
  • Error 2 occurs:
 Interactive([visium_sdata, xenium_sdata])
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 1
----> 1 Interactive([visium_sdata, xenium_sdata])  # , points=False, shapes=False

File ~/miniconda3/envs/SpatialData/lib/python3.10/site-packages/napari_spatialdata/_interactive.py:220, in Interactive.__init__(self, sdata)
    218 self._viewer = napari.Viewer()
    219 self._sdata = sdata
--> 220 self._sdata_widget = SdataWidget(self._viewer, sdata)
    221 self._list_widget = self._viewer.window.add_dock_widget(
    222     self._sdata_widget, name="SpatialData", area="left", menu=self._viewer.window.window_menu
    223 )

File ~/miniconda3/envs/SpatialData/lib/python3.10/site-packages/napari_spatialdata/_interactive.py:56, in SdataWidget.__init__(self, viewer, sdata)
     52 self._viewer = viewer
     54 self.setLayout(QVBoxLayout())
---> 56 self.coordinate_system_widget = CoordinateSystemWidget(self._sdata)
     57 self.elements_widget = ElementWidget(self._sdata)
     59 self.layout().addWidget(QLabel("Coordinate System:"))

File ~/miniconda3/envs/SpatialData/lib/python3.10/site-packages/napari_spatialdata/_interactive.py:42, in CoordinateSystemWidget.__init__(self, sdata)
     38 super().__init__()
     40 self._sdata = sdata
---> 42 self.addItems(self._sdata.coordinate_systems)

AttributeError: 'list' object has no attribute 'coordinate_systems'

More information:

(SpatialData) ➜  ~ pip list | grep spatialdata             
napari-spatialdata            0.2.4
spatialdata                   0.0.10
spatialdata-io                0.0.4
spatialdata-plot              0.0.2
@timtreis
Copy link
Member

@rahulbshrestha do you have an idea why that is happening?

@rahulbshrestha
Copy link

@timtreis This notebook was based off the "spatialdata" branch in napari-spatialdata. The above error is because it used the main branch.

We don't support multiple spatialdata objects in the main branch of the Interactive class right now (scverse/napari-spatialdata#112), which would fix this issue.

@jefferyUstc
Copy link
Author

@timtreis This notebook was based off the "spatialdata" branch in napari-spatialdata. The above error is because it used the main branch.

We don't support multiple spatialdata objects in the main branch of the Interactive class right now (scverse/napari-spatialdata#112), which would fix this issue.

Thank you, I see, hope to see the latest updated documentation soon. once I read the manu from biorxiv, I can't wait to use the framework.

@jefferyUstc
Copy link
Author

BTW, when i run other tutorials, I also got some bugs. I guess it's also raised by the conflicting versions in the releasing ones (pypi) and the ones used in the documentation?

For example:

just load the data and render the image:

import spatialdata_plot

visium_sdata.pl.render_images().pl.render_shapes().pl.show("ST8059049")

It outputs:

image

the last step when overlay the selected region:

f, ax = plt.subplots(figsize=(7, 7))
sdata_ST8059048.pl.render_shapes(color="library", palette="Pastel1").pl.show(ax=ax)
cropped_sdata.pl.render_shapes(color="Sox2").pl.show(ax=ax, colorbar=False)

# show the spatial query bounding box
rect = patches.Rectangle((8000, 12000), 4000, 4000, linewidth=5, edgecolor="k", facecolor="none")
ax.add_patch(rect)
ax.invert_yaxis()

It outputs:
image


FYI:

anndata 0.9.1
dask 2023.5.1
dask-image 2023.3.0
h5py 3.8.0
imageio 2.31.1
matplotlib 3.7.1
matplotlib-inline 0.1.6
matplotlib-scalebar 0.8.1
napari-matplotlib 0.2.1
napari-spatialdata 0.2.4
networkx 3.1
Pillow 9.5.0
scanpy 1.9.3
scikit-image 0.21.0
shapely 2.0.1
spatial_image 0.3.0
spatialdata 0.0.10
spatialdata-io 0.0.4
spatialdata-plot 0.0.2

if any further info needed, donnot hesitate to contact me.

@timtreis
Copy link
Member

Hey @jefferyUstc, thank you for pointing these bugs out! Yeah, we're currently in a bug-squashing phase which hasn't translated to a new pypi release yet. I'll test the aggregation bug and potentially tag you in the issue over at spatialdata_plot if that's where the bug comes from. For the static plotting in particular, we found and fixed quite a few bugs in the last few weeks. So you might want to just use the github main branch for the most stable version so far :)

@LucaMarconato
Copy link
Member

@jefferyUstc thanks for reporting. As mentioned before the problems with napari were caused by the fact that the spatialdata branch was used for visualizing the data with napari and not the main branch. And as @timtreis said, most of the spatialdata-plot bugs should be fixed by now.

The following issues keep track of the bugfix on napari:

There should be only one remaining bug with spatialdata-plot, tracked here:

Since now the problems are tracked elsewhere, I will close the current issue. But if you find new problems that are not tracked by the open issues above, please feel free to reopen this issue.

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

4 participants