Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not convert integer scalar #339

Closed
brianpenghe opened this issue Mar 17, 2020 · 5 comments
Closed

could not convert integer scalar #339

brianpenghe opened this issue Mar 17, 2020 · 5 comments

Comments

@brianpenghe
Copy link

brianpenghe commented Mar 17, 2020

adata=adata[:,~mito_genes]
I was running

sc.pp.filter_cells(adata, min_genes=200)

And got this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-bc34931b4970> in <module>
----> 1 sc.pp.filter_cells(adata, min_genes=200)
      2 sc.pp.filter_genes(adata, min_cells=3)

/usr/local/lib/python3.6/dist-packages/scanpy/preprocessing/_simple.py in filter_cells(data, min_counts, min_genes, max_counts, max_genes, inplace, copy)
    123     if isinstance(data, AnnData):
    124         adata = data.copy() if copy else data
--> 125         cell_subset, number = materialize_as_ndarray(filter_cells(adata.X, min_counts, min_genes, max_counts, max_genes))
    126         if not inplace:
    127             return cell_subset, number

/usr/local/lib/python3.6/dist-packages/anndata/_core/anndata.py in X(self)
    577         elif self.is_view:
    578             X = as_view(
--> 579                 _subset(self._adata_ref.X, (self._oidx, self._vidx)),
    580                 ViewArgs(self, "X"),
    581             )

/usr/lib/python3.6/functools.py in wrapper(*args, **kw)
    805                             '1 positional argument')
    806 
--> 807         return dispatch(args[0].__class__)(*args, **kw)
    808 
    809     funcname = getattr(func, '__name__', 'singledispatch function')

/usr/local/lib/python3.6/dist-packages/anndata/_core/index.py in _subset(a, subset_idx)
    124     if all(isinstance(x, cabc.Iterable) for x in subset_idx):
    125         subset_idx = np.ix_(*subset_idx)
--> 126     return a[subset_idx]
    127 
    128 

/usr/local/lib/python3.6/dist-packages/scipy/sparse/_index.py in __getitem__(self, key)
     73         if row.size == 0:
     74             return self.__class__(np.atleast_2d(row).shape, dtype=self.dtype)
---> 75         return self._get_arrayXarray(row, col)
     76 
     77     def __setitem__(self, key, x):

/usr/local/lib/python3.6/dist-packages/scipy/sparse/compressed.py in _get_arrayXarray(self, row, col)
    663         val = np.empty(major.size, dtype=self.dtype)
    664         csr_sample_values(M, N, self.indptr, self.indices, self.data,
--> 665                           major.size, major.ravel(), minor.ravel(), val)
    666         if major.ndim == 1:
    667             return asmatrix(val)

ValueError: could not convert integer scalar

Any ideas?

@ivirshup
Copy link
Member

ivirshup commented Mar 18, 2020

Not sure. Could you follow up with these?

  • Software versions for scanpy, anndata, scipy, and numpy
  • type(adata) and type(adata.X)

Also, does it work if you do:

adata = adata.copy()
sc.pp.filter_cells(adata, min_genes=200)

@brianpenghe
Copy link
Author

Not sure. Could you follow up with these?

  • Software versions for scanpy, anndata, scipy, and numpy
  • type(adata) and type(adata.X)

Also, does it work if you do:

adata = adata.copy()
sc.pp.filter_cells(adata, min_genes=200)

.copy()
worked!

@abuchin
Copy link

abuchin commented Aug 14, 2020

I have the same problem, but when I run

adata = adata.copy()

it shows the same problem:

...
~/anaconda2/envs/p7/lib/python3.7/site-packages/scipy-1.4.1-py3.7-macosx-10.9-x86_64.egg/scipy/sparse/compressed.py in _get_arrayXarray(self, row, col)
    663         val = np.empty(major.size, dtype=self.dtype)
    664         csr_sample_values(M, N, self.indptr, self.indices, self.data,
--> 665                           major.size, major.ravel(), minor.ravel(), val)
    666         if major.ndim == 1:
    667             return asmatrix(val)

ValueError: could not convert integer scalar

scanpy: 1.4.7.dev63+g0a6bf5ac
anndata: Version('0.7.1')
scipy: 1.4.1
numpy: 1.18.4

@flying-sheep flying-sheep reopened this Aug 14, 2020
@abuchin
Copy link

abuchin commented Aug 26, 2020

Somehow the problem got solved when I updated these libraries.

@ivirshup
Copy link
Member

Thanks for letting us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants