Open leahrosen opened 3 years ago
I just wanted to update that this issue does not depend on scvelo at all, but I can recreate it by just using scanpy. I suspect it is an issue with running umap. I'm using version '0.4.6'. Any help would be much appreciated:
import os
import scanpy as sc
import numpy as np
import pandas as pd
import copy
import anndata
import matplotlib.pyplot as plt
adata_pbmc3k = sc.datasets.pbmc3k_processed()
#del adata_pbmc3k.obsm['X_pca']
#del adata_pbmc3k.obsm['X_umap']
del adata_pbmc3k.obsp['distances']
del adata_pbmc3k.obsp['connectivities']
#sc.pp.pca(adata_pbmc3k, n_comps=50)
sc.pp.neighbors(adata_pbmc3k)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: expected dtype object, got 'numpy.dtype[float32]'
The above exception was the direct cause of the following exception:
SystemError Traceback (most recent call last)
/hps/scratch/lsf_tmpdir/hl-codon-13-02/ipykernel_2124423/1009160698.py in <module>
----> 1 sc.pp.neighbors(adata_pbmc3k)
/hps/software/users/marioni/Leah/miniconda3/envs/scvelo/lib/python3.8/site-packages/scanpy/neighbors/__init__.py in neighbors(adata, n_neighbors, n_pcs, use_rep, knn, random_state, method, metric, metric_kwds, key_added, copy)
137 adata._init_as_actual(adata.copy())
138 neighbors = Neighbors(adata)
--> 139 neighbors.compute_neighbors(
140 n_neighbors=n_neighbors,
141 knn=knn,
/hps/software/users/marioni/Leah/miniconda3/envs/scvelo/lib/python3.8/site-packages/scanpy/neighbors/__init__.py in compute_neighbors(self, n_neighbors, knn, n_pcs, use_rep, method, random_state, write_knn_indices, metric, metric_kwds)
806 # we need self._distances also for method == 'gauss' if we didn't
807 # use dense distances
--> 808 self._distances, self._connectivities = _compute_connectivities_umap(
809 knn_indices,
810 knn_distances,
/hps/software/users/marioni/Leah/miniconda3/envs/scvelo/lib/python3.8/site-packages/scanpy/neighbors/__init__.py in _compute_connectivities_umap(knn_indices, knn_dists, n_obs, n_neighbors, set_op_mix_ratio, local_connectivity)
388
389 X = coo_matrix(([], ([], [])), shape=(n_obs, 1))
--> 390 connectivities = fuzzy_simplicial_set(
391 X,
392 n_neighbors,
/hps/software/users/marioni/Leah/miniconda3/envs/scvelo/lib/python3.8/site-packages/umap/umap_.py in fuzzy_simplicial_set(X, n_neighbors, random_state, metric, metric_kwds, knn_indices, knn_dists, angular, set_op_mix_ratio, local_connectivity, apply_set_operations, verbose)
600 knn_dists = knn_dists.astype(np.float32)
601
--> 602 sigmas, rhos = smooth_knn_dist(
603 knn_dists, float(n_neighbors), local_connectivity=float(local_connectivity),
604 )
SystemError: CPUDispatcher(<function smooth_knn_dist at 0x150524c6cdc0>) returned a result with an error set
time: 3 s (started: 2021-08-23 11:59:12 +01:00)
Apologies for all the edits, but I'm stuck on this so have been playing around with it. Basically I'm getting weird errors when running scanpy on scvelo objects. I first had this issue when running
sc.pp.pca(adata_panc, n_comps=50)
, but managed to solve it by previously settingadata_panc.X = np.array(adata_panc.X.todense())
. However, I'm now getting the exact same error when runningsc.pp.neighbors(adata_panc)
and I'm not sure which matrix to test. Any advice would be very much appreciated!Minimal code sample (that we can copy&paste without having any data)
Versions