You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add more informative error message when pl.render_shapes color table columnhas a missmatch of length #316
sc.pp.filter_cells(sdata.tables["table"],min_counts=10)
sdata.pl.render_shapes("cellpose_boundaries",color="total_counts").pl.show()
File /work/rwth1209/enviroments/spatial_data/lib/python3.9/site-packages/spatialdata_plot/pl/utils.py:264, in _get_collection_shape.<locals>.assign_fill_and_outline_to_row(shapes, fill_c, outline_c, row, idx)
262 row["outline_c"] = outline_c
263 else:
--> 264 row["fill_c"] = fill_c[idx]
265 row["outline_c"] = outline_c[idx]
IndexError: index 3424 is out of bounds for axis 0 with size 3424
sdata.shapes["cellpose_boundaries"] = sdata.shapes["cellpose_boundaries"].loc[sdata.tables["table"].obs.index]
sdata.pl.render_shapes("cellpose_boundaries",color="total_counts").pl.show()
fixed!
I removed some cells from the table but their polygons remained. When plotting this led to a generic error.
Could be a "me" problem but I think it might be good idea to add a more explicit error message that tells the user what is going on. An alternative might be to plot the missmatched polygons with a NaN color
changed the title [-]Add more informative error message when pl.render_shapes color table category has a missmatch of length[/-][+]Add more informative error message when pl.render_shapes color table columnhas a missmatch of length[/+]on Aug 3, 2024
Hey @pakiessling, I'd actually say that in this case it's a "you" problem 😅 You're directly passing theAnnData object, so scanpy cannot really know it's dealing with a spatialdata object and spatialdata would have to do regular consistency checks or sth to notice that you modified the contained AnnData. I added a more explicit error message though.
Activity
[-]Add more informative error message when pl.render_shapes color table category has a missmatch of length[/-][+]Add more informative error message when pl.render_shapes color table columnhas a missmatch of length[/+]timtreis commentedon Aug 15, 2024
Hey @pakiessling, I'd actually say that in this case it's a "you" problem 😅 You're directly passing the
AnnDataobject, soscanpycannot really know it's dealing with aspatialdataobject andspatialdatawould have to do regular consistency checks or sth to notice that you modified the containedAnnData. I added a more explicit error message though.timtreis commentedon Aug 15, 2024
@flying-sheep are there any plans for
scanpyto natively work withSpatialDataobjects? Then this could happen automagicallytimtreis commentedon Aug 15, 2024
@LucaMarconato do we have a similar way of filtering in
spatialdata?LucaMarconato commentedon Aug 15, 2024
Yes, we have the user-friendly match_element_to_table() and match_table_to_element() functions, which are subcases of the more powerful API join_spatialelement_table().
LucaMarconato commentedon Aug 15, 2024
Anyway, I think that the bug reported may be related to this other bug: #169 and not fixable by the user itself. I'll write a MRE in the linked PR.
LucaMarconato commentedon Aug 15, 2024
Same bug, continuing the discussion there. Workaround: manually filtering the shapes so that there are no shapes not in the table.