Teichlab / bbknn

Batch balanced KNN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyError: 'connectivities' while running running UMAP function

aditisk opened this issue · comments

Hello,

I'm following the tutorial which integrates with Scanpy. I was able to successfully run this line of code:

sc.external.pp.bbknn(adata, batch_key='sample_id',metric='euclidean')

In the next step I get this error:

sc.tl.umap(adata)
computing UMAP

KeyError Traceback (most recent call last)
in
----> 1 sc.tl.umap(adata)

/miniconda3/envs/scanpy/lib/python3.7/site-packages/scanpy/tools/_umap.py in umap(adata, min_dist, spread, n_components, maxiter, alpha, gamma, negative_sample_rate, init_pos, random_state, a, b, copy, method)
142 X_umap = simplicial_set_embedding(
143 X,
--> 144 adata.uns['neighbors']['connectivities'].tocoo(),
145 n_components,
146 alpha,

KeyError: 'connectivities'

Am I doing something incorrectly ? How can I fix this problem ? Thanks a lot for your help.

It seems you've got some sort of version incompatibility going on - .uns['neighbors']['connectivities'] used to be where you put your graph back in the day, but it's now .obsp['connectivities']. Try upgrading scanpy and see if that helps?