ebi-gene-expression-group / scanpy-scripts

Scripts for using scanpy
Apache License 2.0
29 stars 13 forks source link

Add fix for exporting mtx from .raw.X #110

Closed pinin4fjords closed 2 years ago

pinin4fjords commented 2 years ago

The current export code is incorrect for .X, assuming as it does that adata.raw is a complete annData object. It's not, and in fact only stores separate versions of .X and .var. So adata.raw.obs does not work, for example, leading to errors like:

AttributeError: 'Raw' object has no attribute 'obs'

... when we try to export .raw.X.

This PR changes things to reference .raw.X and .raw.var only.

I've also fixed use of the layers slot (we've clearly only been using this to export .X!)

pcm32 commented 2 years ago

Out of a first look, this doesn't seem to be covered by any tests. Can we add one please? Thanks.

pinin4fjords commented 2 years ago

Out of a first look, this doesn't seem to be covered by any tests. Can we add one please? Thanks.

Okay, tests added! I know we need to get proper pytest going on this package at some point, but for now this is just via the bats.

pinin4fjords commented 2 years ago

Thanks @pcm32 !