Closed aheravi closed 1 year ago
Hi. I can’t copy/paste/run the above code sample. There’s nowhere you define adata
.
Please add some code that uses some builtin dataset or so and reproduces the error.
Hi, That was from my own datasets, but I also used the data from here, https://github.com/theislab/single-cell-tutorial/blob/master/latest_notebook/Case-study_Mouse-intestinal-epithelium_1906.ipynb, and got the same error.
adata_mnn = adata.copy()
adata_list = [adata_mnn[adata_mnn.obs['sample'] == i] for i in adata_mnn.obs['sample'].unique()]
adata_list
[View of AnnData object with n_obs × n_vars = 2267 × 12818
obs: 'sample', 'region', 'donor', 'n_counts', 'log_counts', 'n_genes', 'mt_frac', 'size_factors'
var: 'gene_id', 'n_cells'
uns: 'log1p'
layers: 'counts',
View of AnnData object with n_obs × n_vars = 1976 × 12818
obs: 'sample', 'region', 'donor', 'n_counts', 'log_counts', 'n_genes', 'mt_frac', 'size_factors'
var: 'gene_id', 'n_cells'
uns: 'log1p'
layers: 'counts',
View of AnnData object with n_obs × n_vars = 1663 × 12818
obs: 'sample', 'region', 'donor', 'n_counts', 'log_counts', 'n_genes', 'mt_frac', 'size_factors'
var: 'gene_id', 'n_cells'
uns: 'log1p'
layers: 'counts',
View of AnnData object with n_obs × n_vars = 2356 × 12818
obs: 'sample', 'region', 'donor', 'n_counts', 'log_counts', 'n_genes', 'mt_frac', 'size_factors'
var: 'gene_id', 'n_cells'
uns: 'log1p'
layers: 'counts',
View of AnnData object with n_obs × n_vars = 2422 × 12818
obs: 'sample', 'region', 'donor', 'n_counts', 'log_counts', 'n_genes', 'mt_frac', 'size_factors'
var: 'gene_id', 'n_cells'
uns: 'log1p'
layers: 'counts',
View of AnnData object with n_obs × n_vars = 1773 × 12818
obs: 'sample', 'region', 'donor', 'n_counts', 'log_counts', 'n_genes', 'mt_frac', 'size_factors'
var: 'gene_id', 'n_cells'
uns: 'log1p'
layers: 'counts']
import mnnpy
corrected = mnnpy.mnn_correct(*adata_list, batch_key="sample")
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-35-7ad830fcd907> in <module>
1 import mnnpy
----> 2 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
This seems related to (and a possible duplicate of) https://github.com/theislab/scanpy/issues/1167, and may be fixed here: https://github.com/chriscainx/mnnpy/pull/41 pending a merge.
As we haven't heard back after the followup link of the fix, we will close the issue for now, hopefully you obtained the expected behaviour in the end :)
However, please don't hesitate to reopen this issue or create a new one if you have any more questions or run into any related problems in the future.
Thanks for being a part of our community! :)
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Minimal code sample (that we can copy&paste without having any data)
Hi Scanpy, I noticed the error was kind of mnnpy related and after checking the issues there and updating two suggested packages, still getting the error.
Versions