Hi @LucaMarconato ! A few days ago, following the instructions in the Use landmark annotations to align multiple -omics layers section, I successfully aligned the layers using data from visium and xenium. However, today I encountered an error when running the add_shapes() function following the same code.
Here is my code:
fromspatialdata.modelsimportShapesModelvisium_landmarks=ShapesModel.parse(
np.array(visium_sdata['visium_temp_points'].drop('z', axis=1)), geometry=0, radius=1000
)
visium_sdata.add_shapes("visium_temp_shape", visium_landmarks, overwrite=True)
xenium_landmarks=ShapesModel.parse(
np.array(xenium_sdata['xenium_temp_points'].drop('z', axis=1)), geometry=0, radius=1000
)
xenium_sdata.add_shapes("xenium_temp_shape", xenium_landmarks, overwrite=True)And here is the error:
RuntimeErrorTraceback (mostrecentcalllast)
CellIn[6], [line6](vscode-notebook-cell:?execution_count=6&line=6)
[1](vscode-notebook-cell:?execution_count=6&line=1) fromspatialdata.modelsimportShapesModel
[3](vscode-notebook-cell:?execution_count=6&line=3) visium_landmarks=ShapesModel.parse(
[4](vscode-notebook-cell:?execution_count=6&line=4) np.array(visium_sdata['visium_temp_points'].drop('z', axis=1)), geometry=0, radius=1000
[5](vscode-notebook-cell:?execution_count=6&line=5) )
----> [6](vscode-notebook-cell:?execution_count=6&line=6) visium_sdata.add_shapes("visium_temp_shape", visium_landmarks, overwrite=True)
[8](vscode-notebook-cell:?execution_count=6&line=8) xenium_landmarks=ShapesModel.parse(
[9](vscode-notebook-cell:?execution_count=6&line=9) np.array(xenium_sdata['xenium_temp_points'].drop('z', axis=1)), geometry=0, radius=[10](vscode-notebook-cell:?execution_count=6&line=10)0010 )
[11](vscode-notebook-cell:?execution_count=6&line=11) xenium_sdata.add_shapes("xenium_temp_shape", xenium_landmarks, overwrite=True)
File [c:\Users\mgssu\anaconda3\envs\spatialData\Lib\site-packages\spatialdata\_core\spatialdata.py:1273](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1273), inSpatialData.add_shapes(self, name, shapes, overwrite)
[1267](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1267) defadd_shapes(
[1268](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1268) self,
[1269](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1269) name: str,
[1270](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1270) shapes: GeoDataFrame,
[1271](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1271) overwrite: bool=False,
[1272](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1272) ) ->None:
-> [1273](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_core/spatialdata.py:1273) _error_message_add_element()
File [c:\Users\mgssu\anaconda3\envs\spatialData\Lib\site-packages\spatialdata\_utils.py:281](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_utils.py:281), in_error_message_add_element()
[280](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_utils.py:280) def_error_message_add_element() ->None:
--> [281](file:///C:/Users/mgssu/anaconda3/envs/spatialData/Lib/site-packages/spatialdata/_utils.py:281) raiseRuntimeError(
...
sdata.labels["labels_name"] =labels
...
Thenewsyntaxdoesnotautomaticallyupdatesthediskstorage, soyouneedtocallsdata.write() whenthein-memoryobjectisreadytobesaved.
TosaveonlyanewspecificelementtoanexistingZarrstoragepleaseusethefunctionswrite_image(), write_labels(), write_points(), write_shapes() andwrite_table(). WearegoingtomakethesecallsmoreergonomicinafollowupPR.In these past few days, I encountered another error while using the polygon_query() function and resolved it based on the suggestions provided in #474. During this process, I updated spatialdata using pip install git+https://github.com/scverse/spatialdata. I'm not sure if this operation caused the error mentioned above.
Hi @LucaMarconato ! A few days ago, following the instructions in the Use landmark annotations to align multiple -omics layers section, I successfully aligned the layers using data from visium and xenium. However, today I encountered an error when running the
add_shapes()function following the same code.Here is my code:
And here is the error:
In these past few days, I encountered another error while using the
polygon_query()function and resolved it based on the suggestions provided in #474. During this process, I updated spatialdata usingpip install git+https://github.com/scverse/spatialdata. I'm not sure if this operation caused the error mentioned above.