Teichlab / bbknn

Batch balanced KNN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bandwidth parameter no longer supported by scanpy or UMAP

ivirshup opened this issue · comments

This was originally reported by a scanpy user here: scverse/scanpy#632.

Scanpy has just removed a frozen version of the umap library we'd been using (PR: scverse/scanpy#576). The current version of umap doesn't support a bandwidth parameter, so now compute_connectivities_umap doesn't either. It looks like this is causing an issue with these lines, where bandwidth is explicitly passed:

bbknn/bbknn/__init__.py

Lines 272 to 274 in 93f25dc

dist, cnts = compute_connectivities_umap(knn_indices, knn_distances, knn_indices.shape[0],
knn_indices.shape[1], bandwidth=bandwidth,
local_connectivity=local_connectivity)

Sorry about the break with so little notice!

Thanks for the catch. Funny story, I just incidentally fixed this today while removing the scanpy dependency from bbknn_pca_matrix. I'll push out 1.3.2 to GitHub and pip today or tomorrow.

Ha, very useful coincidence! Glad to see we didn't break anything important.

Thanks for the quick response!

when I run sc.external.pp.bbknn(adata, batch_key='batch') using scanpy 1.4.2 and bbknn 1.3.2 (upgrade to the latest), I get this error bbknn_pca_matrix() got an unexpected keyword argument 'save_knn'

I took out knn saving as it didn't really serve a practical purpose. It was used for some visualisation in a demonstration notebook ages ago, but then the thing it was visualising got taken out of BBKNN a while ago. Were you actually using it for anything? If not, just take out save_knn=True from your call and you're good.

got the same error using sc.external.pp.bbknn(adata, batch_key='batch', save_knn=True)

Clearly, I will use bbknn.bbknn instead.

import bbknn
bbknn.bbknn(adata, batch_key='batch')

Huh, my bad, the scanpy function uses save_knn internally. Just import bbknn and call bbknn.bbknn() directly, that'll do it. I'll contact the scanpy folks about this.