linnarsson-lab / loom-viewer

Tool for sharing, browsing and visualizing single-cell data stored in the Loom file format
BSD 2-Clause "Simplified" License
35 stars 6 forks source link

Error while trying to view the loom file #162

Closed araksm closed 6 years ago

araksm commented 6 years ago

Hi,
I'm trying to view my loom file in the loom-viewer and am getting an error:

>::1 - - [2018-06-27 17:25:43] "GET /loom HTTP/1.1" 200 767 0.058537
>/Users/me/anaconda/lib/python3.6/site-packages/numpy/lib/arraysetops.py:200: RuntimeWarning: invalid value encountered in not_equal
>  flag = np.concatenate(([True], aux[1:] != aux[:-1]))
>/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_utils.py:93: RuntimeWarning: invalid value encountered in isnan
>  vals[np.isnan(vals)] = 0
>[2018-06-27 17:25:49,372] ERROR in app: Exception on /loom/project/output.loom [GET]
>Traceback (most recent call last):
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_utils.py", line 122, in np_to_list
>    if safe_conversion[i]:
> ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>  File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
>    response = self.full_dispatch_request()
>  File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
>    rv = self.handle_user_exception(e)
>  File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
>    reraise(exc_type, exc_value, tb)
>  File "/Users/me/anaconda/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
>    raise value
>  File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
>    rv = self.dispatch_request()
>  File "/Users/me/anaconda/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
>    return self.view_functions[rule.endpoint](**req.view_args)
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_server.py", line 54, in cache_func
>    response = make_response(view(*args, **kwargs))
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_server.py", line 223, in send_fileinfo
>    attributes = loom_server.datasets.JSON_attributes(project, filename)
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_datasets.py", line 626, in JSON_attributes
>    attributes, last_mod = expander.attributes(False)
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_expand.py", line 227, in attributes
>    rowAttrs = {key: metadata_array(arr) for (key, arr) in ds.ra.items()}
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_expand.py", line 227, in <dictcomp>
>    rowAttrs = {key: metadata_array(arr) for (key, arr) in ds.ra.items()}
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_utils.py", line 147, in metadata_array
>    _data, _data_type = np_to_list(array)
>  File "/Users/me/anaconda/lib/python3.6/site-packages/loom_viewer/loom_utils.py", line 127, in np_to_list
>    return (vals.tolist(), "string")
>AttributeError: 'list' object has no attribute 'tolist'
> ::1 - - [2018-06-27 17:25:49] "GET /loom/project/output.loom HTTP/1.1" 500 412 0.419597

I'm using Python 3.6.0 :: Anaconda 4.3.1 (x86_64) loom v0.32.2

Is there a compatibility issue?

Thank you, Araks

JobLeonard commented 6 years ago
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
During handling of the above exception, another exception occurred:
(...)
AttributeError: 'list' object has no attribute 'tolist'

That's a new one.

araksm commented 6 years ago

Hmm... is there any other information that could be helpful? Could it be related to the loom file quality? Are there any checks I could do?

slinnarsson commented 6 years ago

Hi

Sorry for your troubles. Would you mind sending me the loom file so I can troubleshoot? I suspect there may be some incompatibility of data types.

Have you tried with another loom file, e.g. from loom.linnarssonlab.org ? Those files are known to work, so you can figure out if it's the file or the code that is the problem.

araksm commented 6 years ago

Yes, I can view loom files from loom.linnarssonlab.org without any errors.

Please find attached the file I'm using. It was generated from a Seurat object using loomR R package (https://satijalab.org/loomR/loomR_tutorial.html)

Convert(from=obj, to = "loom", filename = "output.loom")

Thank you very much!

output.loom.zip

slinnarsson commented 6 years ago

Ok, it was due to a subtle difference in how Seurat stores attribute strings. Seurat apparently sometimes stores them as variable-length ascii (technically not conforming to loom specs) which loompy and loom-viewer would read as byte arrays and get confused.

I made a fix so that loompy now understands the variable-length ascii strings, and released it as loompy 2.0.10. Update by doing pip install -U loompy and make sure you get at least 2.0.10. Then it should work.

If you had installed loompy from source using pip install -e ., then a simple git pull in the loompy directory should be sufficient.

araksm commented 6 years ago

Great! It works now. Thank you for fixing.

Vinayaksiv-17 commented 3 years ago

I have the same issue with the loom files I downloaded from the mousebrain.org database. My loompy is the updated version, but still getting the error. The files from loom.linnarsson.org opens fine