-
Notifications
You must be signed in to change notification settings - Fork 33
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
Xenium Ranger 3.0.1.1 after Cellpose resegmentation - "ValueError: A linearring requires at least 4 coordinates." #245
Comments
Is there a temporary workaround to manually create the SpatialData data framework from Xenium ranger output? (I mean a tutorial/notebook/...) |
Nobody have an idea about how to resolve this issue? |
After updating to Xenium Ranger v3.1, still not working. `Traceback (most recent call last): File "./lib/python3.10/site-packages/spatialdata_io/_utils.py", line 46, in wrapper return f(*args, **kwargs) File "./lib/python3.10/site-packages/spatialdata_io/readers/xenium.py", line 232, in xenium polygons["cell_boundaries"] = _get_polygons( File "./lib/python3.10/site-packages/spatialdata_io/readers/xenium.py", line 349, in _get_polygons out = Parallel(n_jobs=n_jobs)( File "./lib/python3.10/site-packages/joblib/parallel.py", line 1918, in call return output if self.return_generator else list(output) File "./lib/python3.10/site-packages/joblib/parallel.py", line 1847, in _get_sequential_output res = func(*args, **kwargs) File "./lib/python3.10/site-packages/spatialdata_io/readers/xenium.py", line 341, in _poly return Polygon(arr[:-1]) File "./lib/python3.10/site-packages/shapely/geometry/polygon.py", line 230, in new shell = LinearRing(shell) File "./lib/python3.10/site-packages/shapely/geometry/polygon.py", line 104, in new geom = shapely.linearrings(coordinates) File "./lib/python3.10/site-packages/shapely/decorators.py", line 77, in wrapper return func(*args, **kwargs) File "./lib/python3.10/site-packages/shapely/creation.py", line 173, in linearrings return lib.linearrings(coords, out=out, **kwargs) ValueError: A linearring requires at least 4 coordinates.` |
Hi,
If you do you, you should certainly also modify the transcripts file and the count matrix; be careful not to modify your raw data, it can be a bit dangerous to do this ! |
Thanks @Lem-P for reporting and thanks @ConstensouxAlexis for sharing a workaround. @Lem-P does this solve your issue? If not, I'll be happy to have a look into this, but please I ask you to share a reproducible script running on some public data to be making it easier to inspect this. Thank you. |
I think this is issue is caused by Xeniumranger import-segmentation and not by spatialdata. When I run xeniumranger with a custom segmentation (Baysor or CellPose), even if I make sure all my segmented cells can be casted to Polygon and have more than 4 vertices, Xeniumranger will create some cells with less than 4 vertices. I haven't figured out yet what could be the problem ! |
Hi, |
In line with @ConstensouxAlexis last comment, as it seems it is Xenium Ranger that introduces these problematic polygons, is there a (easy) way to generate the input files for SpatialData-io without using Xenium Ranger? |
I think that it's fine just to remove problematic polygons; this will only impact the vizualisation and not the analysis |
Thank you, removing the problematic polygons only in the cell_boundaries.parquet file allowed me to make a spatialData object. |
Hey @Lem-P and @ConstensouxAlexis, I linked a PR to this issue which should fix the issue. Could you verify with your data? @LucaMarconato I'm filtering out the polygons and remove the IDs from the table - am I missing something? |
Hello @timtreis, thank you for the PR, I will verify with my data. Just to let you know, this polygon issue is caused by xeniumranger software, and they are currently working on this issue: kharchenkolab/Baysor#153 (comment). Also, the issue with those polygons is only visualization; the associated expression vector in the table is valid, so maybe you shouldn't remove it from the table ? I am not sure what would be the best fix |
Hm, thanks for the extra info! I think given that we are seeing datasets with this issue in the wild now, we know they exist and will cause errors for some users who processed their data with the faulty model. I think my gut feeling would be to leave the error handling and filtering in, but to modify the warning telling the users to reprocess their data with one of the newer versions 🤔 |
We released a new version of XeniumRanger (3.1.1) that fixes the number of polygon vertices error |
Great to hear @LoganAMorrison! However, I think we should still merge that PR since there might be datasets out there generated with the faulty versions. The current implementations tells users what has been filtered, so it's also not sth sneaky in the background. Wdyt @LucaMarconato? |
After segmentation with cellpose, I ran Xenium Ranger 3.0.1.1
xeniumranger import-segmentation --id=my_ID \ --xenium-bundle=$DIR/outs \ --nuclei=$DIR/outs/mask_nuclei.ome_cp_masks.tif \ --cells=$DIR/outs/mask_cells.ome_cp_masks.tif
When I try to read the output folder with spatialdata_io (0.1.7.dev5+g82ff327), spatialdata (0.2.7.dev7+gd746485)
sdata = spatialdata_io.xenium(dir)
I get this error:
"ValueError: A linearring requires at least 4 coordinates."
The text was updated successfully, but these errors were encountered: