While trying to cluster using phenograph I get the error below. Could you help me understand why this happens?
>>adata1
AnnData object with n_obs 脳 n_vars = 77969 脳 18417
obs: 'Id', 'Donor', 'Sample', 'Method', 'Position', 'UMI.Count', 'Expressed.Genes', 'Percent.Mitochond.', 'Percent.Ribo', 'CellType', 'Sex', 'Age'
var: 'name'
uns: 'pca'
obsm: 'X_pca'
varm: 'PCs'
>>import scanpy.external as sce
>>result=sce.tl.phenograph(adata1.obsm['X_pca'],k=100)
PhenoGraph clustering
Finding 100 nearest neighbors using minkowski metric and 'auto' algorithm
Neighbors computed in 67.26673102378845 seconds
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-22-2cf1719c59ce> in <module>
1 import scanpy.external as sce
----> 2 result=sce.tl.phenograph(adata1.obsm['X_pca'],k=100)
/usr/local/lib/python3.8/site-packages/scanpy/external/tl/_phenograph.py in phenograph(data, k, directed, prune, min_cluster_size, jaccard, primary_metric, n_jobs, q_tol, louvain_time_limit, nn_method)
143 )
144
--> 145 communities, graph, Q = phenograph.cluster(
146 data=data,
147 k=k,
/usr/local/lib/python3.8/site-packages/phenograph/cluster.py in cluster(data, clustering_algo, k, directed, prune, min_cluster_size, jaccard, primary_metric, n_jobs, q_tol, louvain_time_limit, nn_method, partition_type, resolution_parameter, n_iterations, use_weights, seed, **kargs)
243 "Leiden completed in {} seconds".format(time.time() - tic_), flush=True,
244 )
--> 245 communities = np.asarray(communities.membership)
246
247 print("Sorting communities by size, please wait ...", flush=True)
/usr/local/lib/python3.8/site-packages/phenograph/core.py in neighbor_graph(kernel, kernelargs)
82 :return graph: n-by-n COO sparse matrix
83 """
---> 84 i, j, s = kernel(**kernelargs)
85 n, k = kernelargs["idx"].shape
86 graph = sp.coo_matrix((s, (i, j)), shape=(n, n))
/usr/local/lib/python3.8/site-packages/phenograph/core.py in parallel_jaccard_kernel(idx)
152 graph.data[i] = tup[1]
153
--> 154 i, j = graph.nonzero()
155 s = graph.tocoo().data
156 return i, j, s[s > 0]
/usr/local/lib/python3.8/site-packages/scipy/sparse/base.py in nonzero(self)
774
775 # convert to COOrdinate format
--> 776 A = self.tocoo()
777 nz_mask = A.data != 0
778 return (A.row[nz_mask], A.col[nz_mask])
/usr/local/lib/python3.8/site-packages/scipy/sparse/base.py in tocoo(self, copy)
904 the resultant coo_matrix.
905 """
--> 906 return self.tocsr(copy=False).tocoo(copy=copy)
907
908 def tolil(self, copy=False):
/usr/local/lib/python3.8/site-packages/scipy/sparse/lil.py in tocsr(self, copy)
475 indices = np.empty(nnz, dtype=idx_dtype)
476 data = np.empty(nnz, dtype=self.dtype)
--> 477 _csparsetools.lil_flatten_to_array(self.rows, indices)
478 _csparsetools.lil_flatten_to_array(self.data, data)
479
_csparsetools.pyx in scipy.sparse._csparsetools.lil_flatten_to_array()
_csparsetools.pyx in scipy.sparse._csparsetools._lil_flatten_to_array_int32()
TypeError: Expected list, got numpy.ndarray
Getting this same identical issue
Also since recently. Used to work like a charm previously, before I update some packages. I guess it has to do with the latter. Any solutions?
I guess it has to do with the dependency on scipy. Downgrading to a previous setup of packages did the trick for me.
Same here, downgrading made everything work
@prubbens @mat10d what version of scipy worked for you?
1.4.1
1.4.2. 1.5.X seemed to break the dependencies.
Hmmm. I am getting this error with scipy 1.4.1. New install of phenograph so I don't have an older version to roll back to. Hopefully they fix this soon!
Phneograph was recently updated and also new wrappers are available in external thanks to @awnimo @Koncopd .
Does this work for you @asmariyaz23 ? I will close this but feel free to reopen
I solved the problem after installing with this command:
pip install scipy==1.4.1 --use-feature=2020-resolver
Most helpful comment
I solved the problem after installing with this command:
pip install scipy==1.4.1 --use-feature=2020-resolver