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

Scipy sparse error: Cannot convert integer scalar #250

Open
le-ander opened this issue Apr 27, 2021 · 1 comment
Open

Scipy sparse error: Cannot convert integer scalar #250

le-ander opened this issue Apr 27, 2021 · 1 comment
Labels

Comments

@le-ander
Copy link
Member

During data store writing we hit this super strange bug again:

SCRIPT loading human_retina_2019_10xsequencing_menon_001_10.1038/s41467-019-12780-8
SCRIPT loading human_thymus_2020_10xsequencing_park_001_10.1126/science.aay3224
SCRIPT loading human_prostategland_2018_10xsequencing_henry_001_10.1016/j.celrep.2018.11.086
SCRIPT loading human_None_2020_scirnaseq_cao_001_10.1126/science.aba7721
Traceback (most recent call last):
  File "/storage/groups/ml01/code/leander.dony/sfaira/sfaira/data/utils_scripts/write_store.py", line 20, in <module>
    ds.streamline_features(
  File "/storage/groups/ml01/code/leander.dony/sfaira/sfaira/data/base/dataset.py", line 633, in streamline_features
    x_new[:, idx_feature_map[i:i + step]] = x[:, i:i + step]
  File "/opt/python/lib/python3.8/site-packages/scipy/sparse/_index.py", line 116, in __setitem__
    self._set_arrayXarray_sparse(i, j, x)
  File "/opt/python/lib/python3.8/site-packages/scipy/sparse/compressed.py", line 807, in _set_arrayXarray_sparse
    self._zero_many(*self._swap((row, col)))
  File "/opt/python/lib/python3.8/site-packages/scipy/sparse/compressed.py", line 927, in _zero_many
    ret = csr_sample_offsets(M, N, self.indptr, self.indices, n_samples,
ValueError: could not convert integer scalar

We already copy the matrix over in chunks to circumvent this issue (was fine like this for a year now):

# copying this over to the new matrix in chunks of size `steps` prevents a strange scipy error:
# ... scipy/sparse/compressed.py", line 922, in _zero_many i, j, offsets)
# ValueError: could not convert integer scalar
step = 2000
if step < len(idx_feature_map):
i = 0
for i in range(0, len(idx_feature_map), step):
x_new[:, idx_feature_map[i:i + step]] = x[:, i:i + step]
x_new[:, idx_feature_map[i + step:]] = x[:, i + step:]

I'll try and reduce step size and see if this goes away again (human_None_2020_scirnaseq_cao_001_10.1126/science.aba7721 has a very large number of features I think, which could cause this to break again)

@le-ander
Copy link
Member Author

step size of 500 seems to do the trick. this is something we should at some point fix properly though

@le-ander le-ander changed the title Cannot convert integer scalar Scipy sparse error: Cannot convert integer scalar Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant