gustaveroussy / sopa

Technology-invariant pipeline for spatial omics analysis (Xenium / MERSCOPE / CosMx / PhenoCycler / MACSima / Hyperion) that scales to millions of cells
https://gustaveroussy.github.io/sopa/
BSD 3-Clause "New" or "Revised" License
94 stars 8 forks source link

sopa.segmentation.baysor.resolve error: Raise ValueError('negative column index found') ValueError: negative column index found #75

Closed mamyAndrianteranagna closed 1 week ago

mamyAndrianteranagna commented 4 weeks ago

Dear Quentin Blampey,

Thank you for developping this awsome framework.

We try it on MERFISH data using baysor, but we have an issue at the resolve step, while the segmentation step itself was working well.o0

This is the error I got after running the function sopa.segmentation.baysor.resolve()

NumbaDeprecationWarning: The 'nopython' keyword argu\ ment was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readth\ edocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details. def twobit_1hamming(twobit: int, size: int) -> List[int]: Reading baysor outputs: 75%|██████████████████████████▎ | 6/8 [00:15<00:04, 2.21s/it][WARNING] (sopa.segmentation.shapes) Removing cell of unknown type <class 'shapely.geometry.mul\ tilinestring.MultiLineString'> Reading baysor outputs: 100%|███████████████████████████████████| 8/8 [00:18<00:00, 2.36s/it] Resolving conflicts: 100%|██████████████████████████████| 2480/2480 [00:00<00:00, 3637.14it/s] [INFO] (sopa.segmentation.baysor.resolve) Aggregating transcripts on merged cells [INFO] (sopa.segmentation.aggregate) Aggregating transcripts over 418 cells [############## ] | 37% Completed | 23.95 s Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/sopa/segmentation/baysor/resolve.py", line 131, in resolve table_conflicts = aggregate.count_transcripts(sdata, gene_column, geo_df=geo_df_new) File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/sopa/segmentation/aggregate.py", line 289, in count_transcripts return _count_transcripts_aligned(geo_df, points, gene_column) File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/sopa/segmentation/aggregate.py", line 318, in _count_transcripts_ali\ gned ).compute() File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/dask/base.py", line 379, in compute (result,) = compute(self, traverse=False, **kwargs) File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/dask/base.py", line 665, in compute results = schedule(dsk, keys, **kwargs) File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/sopa/segmentation/aggregate.py", line 337, in _add_coo adata.X += coo_matrix( File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/scipy/sparse/_coo.py", line 204, in __init__ self._check() File "/data/kdi_prod/.kdi/project_workspace_0/1928/acl/01.00/scripts/conda_telocytes_sopa/lib/python3.10/site-packages/scipy/sparse/_coo.py", line 297, in _check raise ValueError('negative column index found') ValueError: negative column index found

Here is the baysor config I used: config = { "data": { "force_2d": True, "min_molecules_per_cell": 10, "x": "x", "y": "y", "z": "z", "gene": "gene", "min_molecules_per_gene": 0, "min_molecules_per_segment": 3, "confidence_nn_id": 6 }, "segmentation": { "scale": 10, # Important parameter: typical cell diameter, in microns (see our configs) "scale_std": "25%", "prior_segmentation_confidence": 0, "estimate_scale_from_centers": False, "n_clusters": 4, "iters": 500, "n_cells_init": 0, "nuclei_genes": "", "cyto_genes": "", "new_component_weight": 0.2, "new_component_fraction": 0.3 } }

I run it using the environment below on a CentOS7 cluster. Let me know if you need more informations.

Regards, Mamy

PS: here is my environment: env.txt

quentinblampey commented 4 weeks ago

Hello @mamyAndrianteranagna, According to your error log, it seems that you have an old version of Sopa. Can you update it and see if you still have the same issue? Either pip install sopa --upgrade (if you installed Sopa with PyPI) or git pull if you cloned the repository

mamyAndrianteranagna commented 1 week ago

Hi Quentin,

Thanks for your reply. I'm wondering about the version also but not sure, I will update everything. I will let you know.

Best, Mamy

mamyAndrianteranagna commented 1 week ago

Hello Quentin,

The problem disappear after re-builting my environment with the latest version of sopa.

Thanks a lot!

Regards, Mamy