phenograph Expected list, got numpy.ndarray
See original GitHub issueWhile 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
phenograph Expected list, got numpy.ndarray #1407 - GitHub
While trying to cluster using phenograph I get the error below. Could you help me understand why this happens? >>adata1 AnnData object with ......
Read more >Creating a pandas DataFrame from a list followed by an array ...
The first element of list is checked. If it's a list then it proceeds into listlike block but if its ndarray it proceeds...
Read more >PhenoGraph - Python Package Health Analysis - Snyk
Expected use is within a script or interactive kernel running Python 3.x . Data are expected to be passed as a numpy.ndarray ....
Read more >Why do I get "TypeError: expected np.ndarray (got numpy ...
Hello It seems you are getting the error because the argument to from_numpy function is a single value rather than array. In numpy,...
Read more >scanpy.external.tl.phenograph - Read the Docs
PhenoGraph is a clustering method designed for high-dimensional single-cell data. It works by creating a graph (“network”) representing phenotypic similarities ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I solved the problem after installing with this command:
pip install scipy==1.4.1 --use-feature=2020-resolver
I guess it has to do with the dependency on
scipy. Downgrading to a previous setup of packages did the trick for me.