question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

row attributes can't be lists as list has no shape attribute when loompy.create is used.

See original GitHub issue

python 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:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
slinnarssoncommented, Nov 1, 2018

Fixed by da40971a4734facb883cdfe4dbdbab975ed16faa, and will be included in the next release.

0reactions
FionaMooncommented, Jul 20, 2022

I still got this error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

loompy 3.0.6 documentation - Linnarsson Lab
AttributeManager (self, axis=0) #: Row attributes, dict-like with ... the file has no timestamp, and mode is 'r+', a new timestamp is created...
Read more >
'list' object has no attribute 'shape' - python - Stack Overflow
list object in python does not have 'shape' attribute because 'shape' implies that all the columns (or rows) have equal length along certain ......
Read more >
AttributeError: 'list' object has no attribute 'shape' | bobbyhadz
The Python AttributeError: 'list' object has no attribute 'shape' occurs when we try to access the `shape` attribute on a list. To solve...
Read more >
Big Ideas for Early Learning - Ohio Department of Education
Children demonstrate understanding of the attributes of objects, people, and/or events using color, quality, shape, and texture concepts and terms. • color ...
Read more >
ANAEROBIC SLUDGE DIGESTION PROCESS
Water used to carry waste products away from homes, schools, commercial establishments, and industrial enterprises. Sources of Wastewater. Domestic.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found