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

Errors encountered when running the function sciPENN_API(...) #4

Open
CCCC1800 opened this issue Nov 25, 2023 · 4 comments
Open

Errors encountered when running the function sciPENN_API(...) #4

CCCC1800 opened this issue Nov 25, 2023 · 4 comments

Comments

@CCCC1800
Copy link

Hi, I followed your tutorial "tutorial.ipynb" at your website https://drive.google.com/drive/folders/1iY4s76UYNMFvF6v3XN4JxD9gM77NIxoH. However, I got an error when running the following function:

sciPENN = sciPENN_API(gene_trainsets = [adata_gene_train], protein_trainsets = [adata_protein_train],
gene_test = adata_gene_test, train_batchkeys = ['donor'], test_batchkey = 'donor',
type_key = 'celltype.l3')

I got the following error:


TypeError Traceback (most recent call last)
TypeError: expected dtype object, got 'numpy.dtype[float64]'

The above exception was the direct cause of the following exception:

SystemError Traceback (most recent call last)
/var/folders/vn/xxwlw_f508gclgvh8ldr47sw0000gn/T/ipykernel_72171/2889813855.py in
1 sciPENN = sciPENN_API(gene_trainsets = [adata_gene_train], protein_trainsets = [adata_protein_train],
2 gene_test = adata_gene_test, train_batchkeys = ['donor'], test_batchkey = 'donor',
----> 3 type_key = 'celltype.l3')

~/opt/anaconda3/envs/scipennenv/lib/python3.7/site-packages/sciPENN/sciPENN_API.py in init(self, gene_trainsets, protein_trainsets, gene_test, gene_list, select_hvg, train_batchkeys, test_batchkey, type_key, cell_normalize, log_normalize, gene_normalize, min_cells, min_genes, batch_size, val_split, use_gpu)
35 gene_list, select_hvg, cell_normalize, log_normalize, gene_normalize, min_cells, min_genes)
36
---> 37 genes, proteins, genes_test, bools, train_keys, categories = preprocess(*preprocess_args)
38
39 self.proteins = proteins

~/opt/anaconda3/envs/scipennenv/lib/python3.7/site-packages/sciPENN/Preprocessing.py in preprocess(gene_trainsets, protein_trainsets, gene_test, train_batchkeys, test_batchkey, type_key, gene_list, select_hvg, cell_normalize, log_normalize, gene_normalize, min_cells, min_genes)
145
146 sc.pp.highly_variable_genes(tmp, min_mean = 0.0125, max_mean = 3, min_disp = 0.5,
--> 147 n_bins = 20, subset = False, batch_key = 'batch', n_top_genes = 1000)
148 hvgs = tmp.var.index[tmp.var['highly_variable']].copy()
149 tmp = None

~/opt/anaconda3/envs/scipennenv/lib/python3.7/site-packages/scanpy/preprocessing/_highly_variable_genes.py in highly_variable_genes(adata, layer, n_top_genes, min_disp, max_disp, min_mean, max_mean, span, n_bins, flavor, subset, inplace, batch_key, check_values)
472 n_top_genes=n_top_genes,
473 n_bins=n_bins,
--> 474 flavor=flavor,
475 )
476

~/opt/anaconda3/envs/scipennenv/lib/python3.7/site-packages/scanpy/preprocessing/_highly_variable_genes.py in _highly_variable_genes_single_batch(adata, layer, min_disp, max_disp, min_mean, max_mean, n_top_genes, n_bins, flavor)
200 X = np.expm1(X)
201
--> 202 mean, var = materialize_as_ndarray(_get_mean_var(X))
203 # now actually compute the dispersion
204 mean[mean == 0] = 1e-12 # set entries equal to zero to small value

~/opt/anaconda3/envs/scipennenv/lib/python3.7/site-packages/scanpy/preprocessing/_utils.py in _get_mean_var(X, axis)
6 def _get_mean_var(X, *, axis=0):
7 if sparse.issparse(X):
----> 8 mean, var = sparse_mean_variance_axis(X, axis=axis)
9 else:
10 mean = np.mean(X, axis=axis, dtype=np.float64)

~/opt/anaconda3/envs/scipennenv/lib/python3.7/site-packages/scanpy/preprocessing/_utils.py in sparse_mean_variance_axis(mtx, axis)
40 )
41 else:
---> 42 return sparse_mean_var_minor_axis(mtx.data, mtx.indices, *shape, np.float64)
43
44

SystemError: CPUDispatcher(<function sparse_mean_var_minor_axis at 0x7fa7200328c8>) returned a result with an error set.

@CCCC1800
Copy link
Author

CCCC1800 commented Nov 25, 2023

Before encountering this error, I already had all the dependencies installed the same version as the software requirement written on your github.
My python version is 3.7.0.
In my conda environment "scipennenv", I had the following package versions:
torch=1.13.1
scanpy=1.9.3
pandas=1.1.5
numpy=1.21.6
scipy=1.7.3
tqdm=4.66.1
anndata=0.8.0
numba=0.50.0

Also, the active kernel I use is:
Python [conda env:scipennenv]

The reported error is encountered based on these settings.

@fisherj-2212
Copy link

I am also experiencing this error using a conda env built from the .yaml provided.

@fisherj-2212
Copy link

fisherj-2212 commented Jan 22, 2024

For future reference, I have gotten the software working by doing the following. It appears updating numba to a higher version than indicated in the dependencies is required. To do this I created a conda env from this .yml file which simply sets up the env with a suitable version of python and pip

name: scipenn_env_testing
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.7.0
  - pip>=21.2.4
prefix:  /export/home/jfisher2/mambaforge/envs/scipenn_env_testing

and then ran the following package installation commands in terminal

  pip install llvmlite==0.36 --ignore-installed
  pip install sciPENN --ignore-installed
  mamba install numba==0.53.0

Not the most elegant solution, but the sciPENN_API function does now run as expected.

@Genshin-Impact-king
Copy link

Is there any other solution?

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

3 participants