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.

regress_out failed in the pbmc3k tutorial

See original GitHub issue

AxisError was encountered while executing the regress_out function following the pbmc3k tutorial …

sc.pp.regress_out(adata, ['n_counts', 'percent_mito'])
regressing out ['n_counts', 'percent_mito']
    sparse input is densified and may lead to high memory use
---------------------------------------------------------------------------
AxisError                                 Traceback (most recent call last)
<ipython-input-55-c0d016811ded> in <module>
----> 1 sc.pp.regress_out(adata, ['n_counts', 'percent_mito'])

~/anaconda3/envs/scanpy/lib/python3.6/site-packages/scanpy/preprocessing/_simple.py in regress_out(adata, keys, n_jobs, copy)
    817     # split the adata.X matrix by columns in chunks of size n_chunk
    818     # (the last chunk could be of smaller size than the others)
--> 819     chunk_list = np.array_split(adata.X, n_chunks, axis=1)
    820     if variable_is_categorical:
    821         regressors_chunk = np.array_split(regressors, n_chunks, axis=1)

<__array_function__ internals> in array_split(*args, **kwargs)

~/anaconda3/envs/scanpy/lib/python3.6/site-packages/numpy/lib/shape_base.py in array_split(ary, indices_or_sections, axis)
    782 
    783     sub_arys = []
--> 784     sary = _nx.swapaxes(ary, axis, 0)
    785     for i in range(Nsections):
    786         st = div_points[i]

<__array_function__ internals> in swapaxes(*args, **kwargs)

~/anaconda3/envs/scanpy/lib/python3.6/site-packages/numpy/core/fromnumeric.py in swapaxes(a, axis1, axis2)
    595 
    596     """
--> 597     return _wrapfunc(a, 'swapaxes', axis1, axis2)
    598 
    599 

~/anaconda3/envs/scanpy/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
     56     bound = getattr(obj, method, None)
     57     if bound is None:
---> 58         return _wrapit(obj, method, *args, **kwds)
     59 
     60     try:

~/anaconda3/envs/scanpy/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)
     45     except AttributeError:
     46         wrap = None
---> 47     result = getattr(asarray(obj), method)(*args, **kwds)
     48     if wrap:
     49         if not isinstance(result, mu.ndarray):

AxisError: axis1: axis 1 is out of bounds for array of dimension 0

Versions:

scanpy==1.4.5.post3 anndata==0.7.1 umap==0.3.10 numpy==1.18.1 scipy==1.4.1 pandas==0.25.3 scikit-learn==0.22.1 statsmodels==0.11.0 python-igraph==0.7.1 louvain==0.6.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
d-j-kcommented, Jan 27, 2020

It looks like this is connected to the way anndata objects are sliced. An explicit adata = adata.copy() before calling sc.pp.regress_out() solves the problem.

1reaction
naitycommented, Jan 27, 2020

I had the exact same issue and error message at that step in the tutorial. I installed scanpy using pip, because installing with conda was not working.

Same here. I assume there is some issue with the implementation of the setter of adata.X, which prevents adata.X = adata.X.toarray() from updating X to its densified version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

regress_out failed in the pbmc3k tutorial · Issue #1010 - GitHub
AxisError was encountered while executing the regress_out function following the pbmc3k tutorial ... sc.pp.regress_out(adata, ['n_counts', ...
Read more >
Clustering 3K PBMCs with Scanpy - Galaxy Training!
In this tutorial, we will investigate clustering of single-cell data from 10x Genomics, including preprocessing, clustering and the identification of cell types ...
Read more >
Seurat - Guided Clustering Tutorial - Satija Lab
For this tutorial, we will be analyzing the a dataset of Peripheral Blood Mononuclear Cells (PBMC) freely available from 10X Genomics. There are ......
Read more >
pbmc10k - Pitt CRC
Regress out effects of total counts per cell and the percentage of mitochondrial genes expressed. Scale the data to unit variance. In [19]:....
Read more >
Seurat.pdf - R Project
Error bound on the neighbor finding algorithm (from RANN/Annoy) verbose ... Cluster this distance matrix to determine a guide tree ...
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