'AnnData' object error
See original GitHub issueHi there, Facing the following error:
scv.utils.show_proportions(sdata)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-33-6e397acd5750> in <module>()
----> 1 scv.utils.show_proportions(sdata)
/Users/awilk/anaconda3/lib/python3.6/site-packages/scvelo/preprocessing/utils.py in show_proportions(adata)
20 """
21 layers_keys = [key for key in ['spliced', 'unspliced', 'ambiguous'] if key in adata.layers.keys()]
---> 22 counts_per_cell_layers = [adata.layers[key].sum(1) for key in layers_keys]
23
24 counts_per_cell_sum = np.sum(counts_per_cell_layers, 0)
/Users/awilk/anaconda3/lib/python3.6/site-packages/scvelo/preprocessing/utils.py in <listcomp>(.0)
20 """
21 layers_keys = [key for key in ['spliced', 'unspliced', 'ambiguous'] if key in adata.layers.keys()]
---> 22 counts_per_cell_layers = [adata.layers[key].sum(1) for key in layers_keys]
23
24 counts_per_cell_sum = np.sum(counts_per_cell_layers, 0)
AttributeError: 'AnnData' object has no attribute 'sum'
Same error is coming up with scv.pp.filter_genes(), scv.pp.normalize_per_cell(), etc. Some more info:
sdata
AnnData object with n_obs × n_vars = 17829 × 14152
obs: 'orig.ident', 'clusters'
obsm: 'UMAP_1', 'UMAP_2'
layers: 'spliced', 'unspliced', 'ambiguous'
sdata.layers['spliced'], sdata.layers['unspliced']
(<17829x14152 sparse matrix of type '<class 'numpy.float32'>'
with 25134338 stored elements in Compressed Sparse Row format>,
AnnData object with n_obs × n_vars = 17829 × 14152 )
sdata.layers['spliced'].sum(1), sdata.layers['unspliced'].sum(1)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-38-2dd9862f1041> in <module>()
----> 1 sdata.layers['spliced'].sum(1), sdata.layers['unspliced'].sum(1)
AttributeError: 'AnnData' object has no attribute 'sum'
The raw data are there, but it seems there must be something wrong about the way I’m storing it? (probably a simple fix I’m just missing). Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Release Notes — anndata 0.7.8 documentation
AnnData object created from dataframes with sparse values will have sparse .X PR 395 I Virshup. Bug fixes. Fixed error from AnnData.concatenate by...
Read more >Downstream analysis based on Anndata object | DESC
Convert AnnData object in python to Seurat object in R ... raw.data.matrix <- tryCatch( expr = t(py_to_r(from$raw$X)), error = function(e) { stop("No ...
Read more >Error of inspect anndata - usegalaxy.eu support - Galaxy Help
... do “the full data matrix” inspect with " Inspect AnnData object", I always get the ERROR, I help you can help me...
Read more >Pegasus - Google Groups
I'm getting the error “'AnnData' object has no attribute 'register_attr'” when trying to use pg.calc_kBET() and also pg.neighbors().
Read more >theislab/zellkonverter source: R/AnnData2SCE.R - Rdrr.io
Values stored in the `varm` slot of an `AnnData` object are stored in a ... error = function(err) { # If whole list...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re right, the way I was writing the AnnData object only wrote into the spliced layer. I do all of my pre-processing in R, and so I’m trying to create the AnnData object using .mtx files written from R. This odd-looking workaround allowed me to write into all layers of the AnnData object, but still appears to throw errors downstream:
Looks like a whole anndata object is stored in
sdata.layers['unspliced']
, which does not make sense… The raw data - if needed later on - is to be stored insdata.raw
. Did you write that to unspliced layers?