row attributes can't be lists as list has no shape attribute when loompy.create is used.
See original GitHub issuepython 3.6.3 loompy version: 2.0.15
For the following code modeled after the API examples https://linnarssonlab.org/loompy/apiwalkthrough/index.html#row-and-column-attributes where it is suggested that you can create row and columns attributes from pandas dataframes by converting them to dictionaries of lists https://linnarssonlab.org/loompy/cookbook/index.html#loading-attributes-from-pandas.
However using a similar approach for my data i get the following error
raceback (most recent call last):
File "/home/user/.local/bin/combine_stringtie_expression.py", line 125, in <module>
main()
File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/user/.local/bin/combine_stringtie_expression.py", line 122, in main
combine_files(stringtieabundance, outdir, genenamesfile)
File "/home/user/.local/bin/combine_stringtie_expression.py", line 109, in combine_files
loompy.create(outdir + ".loom", sp.csc_matrix(TPM), row_attr, col_attr)
File "/home/user/.virtualenvs/singleCellAnalysis/lib/python3.6/site-packages/loompy/loompy.py", line 995, in create
if ra.shape[0] != shape[0]:
AttributeError: 'list' object has no attribute 'shape'
It looks like when loompy checks that the row attribute length coincides with the shape of the data it assumes the shape attribute is available. When I create my row attribute
row_attr = TPM.index.to_frame().to_dict("list")
loompy.create(outdir + ".loom", sp.csc_matrix(TPM), row_attr, col_attr)
i create a dict of lists. Is this a bug or am I missing something. Currently I fix this by converting the list to an numpy.array.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Fixed by da40971a4734facb883cdfe4dbdbab975ed16faa, and will be included in the next release.
I still got this error.