mnnpy icon indicating copy to clipboard operation
mnnpy copied to clipboard

arrays used as indices must be of integer (or boolean) type

Open aheravi opened this issue 5 years ago • 12 comments

Hi mnnpy, I am getting an error using mnnpy.mnn_correct and wondering if you could please comment on my error. I have the latest version of numba and llvmlite.

Here is what I used:

adata_list = [adata_mnn[adata_mnn.obs['sample'] == i] for i in adata_mnn.obs['sample'].unique()]
corrected = mnnpy.mnn_correct(*adata_list, batch_key="sample")

and the error:

Starting MNN correct iteration. Reference batch: 0
Step 1 of 4: processing batch 1
  Looking for MNNs...

  Computing correction vectors...

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-43-69e6e2b5cdef> in <module>
----> 1 corrected = mnnpy.mnn_correct(*adata_list, batch_key="sample")

/Anaconda_python3/lib/python3.7/site-packages/mnnpy/mnn.py in mnn_correct(var_index, var_subset, batch_key, index_unique, batch_categories, k, sigma, cos_norm_in, cos_norm_out, svd_dim, var_adj, compute_angle, mnn_order, svd_mode, do_concatenate, save_raw, n_jobs, *datas, **kwargs)
    124                                 cos_norm_out=cos_norm_out, svd_dim=svd_dim, var_adj=var_adj,
    125                                 compute_angle=compute_angle, mnn_order=mnn_order,
--> 126                                 svd_mode=svd_mode, do_concatenate=do_concatenate, **kwargs)
    127         print('Packing AnnData object...')
    128         if do_concatenate:

/Anaconda_python3/lib/python3.7/site-packages/mnnpy/mnn.py in mnn_correct(var_index, var_subset, batch_key, index_unique, batch_categories, k, sigma, cos_norm_in, cos_norm_out, svd_dim, var_adj, compute_angle, mnn_order, svd_mode, do_concatenate, save_raw, n_jobs, *datas, **kwargs)
    180         print('  Computing correction vectors...')
    181         correction_in = compute_correction(ref_batch_in, new_batch_in, mnn_ref, mnn_new,
--> 182                                            new_batch_in, sigma)
    183         if not same_set:
    184             correction_out = compute_correction(ref_batch_out, new_batch_out, mnn_ref, mnn_new,

IndexError: arrays used as indices must be of integer (or boolean) type

and finally the version of the packages:

mnnpy==0.1.9.5
numpy==1.19.1 scipy==1.5.0 pandas==1.0.5 scikit-learn==0.23.1 statsmodels==0.11.1 python-igraph==0.8.2 louvain==0.7.0 leidenalg==0.8.1
numba==0.50.1
llvmlite==0.33.0+1.g022ab0f

aheravi avatar Aug 13 '20 15:08 aheravi

Having the identical error here. Happening at step 2 of 4.

Gpasquini avatar Aug 17 '20 09:08 Gpasquini

Same issue here. I traced it to compute_correction. Of note is that mnn_ref and mnn_new are empty, which may be causing the error.

csgroen avatar Oct 21 '20 12:10 csgroen

@csgroen Were you able to resolve the error? I am getting the exact same error and mnn_ref and mnn_new are empty for me as well.

ebruder avatar Dec 09 '20 13:12 ebruder

@ebruder no, I ended up switching strategies and didn't use this method

csgroen avatar Dec 09 '20 13:12 csgroen

@csgroen Is there any other python packages you know doing MNNcorrect?

ebruder avatar Dec 09 '20 13:12 ebruder

@chriscainx any suggestions on how to resolve this issue of mnn_ref and mnn_new being empty out of find_mutual_nn()?

ebruder avatar Dec 09 '20 13:12 ebruder

Any solution here? I still cannot solve this problem.

HelloWorldLTY avatar Apr 14 '21 10:04 HelloWorldLTY

maybe this problem was caused by numba package,u can modifiy utils.py,when i deleted some lines including @jit,i solved this problem.

dongzuoyk avatar Jun 18 '21 10:06 dongzuoyk

Hi, I have another method to solve it. We can enlarge the value of k, for example using k=2000 rather than k=20, it can also solve the problem. However, I cannot guarantee that it will lead to the best performance of mnn.

HelloWorldLTY avatar Jun 18 '21 13:06 HelloWorldLTY

Hi, I've solved the issue using this package setup

- anndata==0.7.1
- fa2==0.3.5
- h5py==2.9.0
- loompy==2.0.17
- numpy==1.17.3
- pandas==0.25.3
- scanpy==1.4.4.post1
- scikit-learn==0.22.1
- numba==0.45.0
- llvmlite==0.31.0
- mnnpy==0.1.9.5
- cython==0.29.14
- python-igraph==0.9.6
- umap-learn==0.3.10
- llvmlite==0.30

matq007 avatar Aug 13 '21 13:08 matq007

Same problem here. Are there any method to solve this issue?

melancholy12 avatar Feb 06 '22 22:02 melancholy12

Same problem here. Are there any method to solve this issue?

I implemented a new version without such program. You can take a look at it here:

https://github.com/HelloWorldLTY/mnnpy

HelloWorldLTY avatar Feb 07 '22 02:02 HelloWorldLTY