squidpy
squidpy copied to clipboard
error loading Nanosctring CosMx dataset
Hi, good day. Thank you for the very nice package.
I have an issue loading the Nanostring CosMx dataset: Nanosctring CosMx dataset
Here is the error I am getting:
Traceback (most recent call last): File "/mnt/c/Users/mohebg/Desktop/newscanpyinR/.venv/lib/python3.7/site-packages/scipy/sparse/base.py", line 322, in asformat return convert_method(copy=copy) File "/mnt/c/Users/mohebg/Desktop/newscanpyinR/.venv/lib/python3.7/site-packages/scipy/sparse/coo.py", line 404, in tocsr data = np.empty_like(self.data, dtype=upcast(self.dtype)) File "/mnt/c/Users/mohebg/Desktop/newscanpyinR/.venv/lib/python3.7/site-packages/scipy/sparse/sputils.py", line 51, in upcast raise TypeError('no supported conversion for types: %r' % (args,)) TypeError: no supported conversion for types: (dtype('O'),)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
hi @GhobrialMoheb unfortunately I am not able to help with this error message, can you try to create the anndata from the various files instead of reading it with the squidpy function? also I would make sure you have the latest version of squidpy
Hi @GhobrialMoheb ,
I tried to load my own CosMx data generated in our facility using squidpy.read.nanostring
function and got the same TypeError. Looking into it, it seems that the error was raised because my "<sample_id>_exprMat_file.csv" had an additional column named "cell" which represented cell IDs in string type. The ID values in it were in the format of "c_<slide>_<fov>_<cell_ID>"- e.g.: "c_1_1_1". In my data, it was the third column in the CSV.
I was able to overcome the issue by removing this column using a simple cut
function:
cut -d, -f3 --complement <sample_id>_exprMat_file.csv > <sample_id>_exprMat_new_file.csv
I'm not 100% sure that this was your problem also, but it's worth a try.
Best, Einan
Hi @GhobrialMoheb, for loading CosMx datasets efficiently I would highly recommend to use spatialdata-io, which has a reader for CosMx called cosmx()
.