Closed alasla closed 4 years ago
Thanks for the heads up, will update soon. How new a version we talking here? As this way I can add appropriate version information to the dependencies.
Just to whom it may concern, I also learned the hard way, I was puzzled why bbknn was not working and found that for
scanpy==1.5.1 anndata==0.7.1 umap==0.3.10 numpy==1.18.1 scipy==1.4.1 pandas==1.0.1 scikit-learn==0.22.2 statsmodels==0.11.1 python-igraph==0.8.2 leidenalg==0.8.0
the interim solution could be:
distances, connectivities = bbknn.bbknn_pca_matrix(adata.obsm["X_pca"], adata.obs['sample'])
adata_bbknn.obsp['distances'] = distances
adata_bbknn.obsp['connectivities'] = connectivities
Thanks for the reminder. I checked the release history for anndata
, found out they restructured in 0.7, thought up a way to check the package version and store in .obsp
or .uns
accordingly, and then got a case of lockdown brain and never followed through. I'll try to push this out soon. My apologies.
Released as 1.3.10. Sorry about the delay again.
@ktpolanski
I am getting this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-1a416d7acffc> in <module>
----> 1 adata_bbknn = bbknn.bbknn(adata, batch_key='batch2', n_pcs=16, trim=0, copy=True)
2 # Fix of bbknn
3 #adata_bbknn.obsp['distances'] = adata_bbknn.uns['neighbors']['distances']
4 #adata_bbknn.obsp['connectivities'] = adata_bbknn.uns['neighbors']['connectivities']
5 sc.tl.umap(adata_bbknn, min_dist=0.3)
~/anaconda3/envs/jlab/lib/python3.8/site-packages/bbknn/__init__.py in bbknn(adata, batch_key, use_rep, approx, metric, copy, **kwargs)
296 adata.uns['neighbors']['params']['bbknn']['batch_key'] = batch_key
297 #store the graphs in .uns['neighbors'] or .obsp, conditional on anndata version
--> 298 if version.parse(anndata.__version__) < version.parse('0.7.0'):
299 adata.uns['neighbors']['distances'] = bbknn_out[0]
300 adata.uns['neighbors']['connectivities'] = bbknn_out[1]
~/anaconda3/envs/jlab/lib/python3.8/site-packages/packaging/version.py in parse(version)
54 """
55 try:
---> 56 return Version(version)
57 except InvalidVersion:
58 return LegacyVersion(version)
~/anaconda3/envs/jlab/lib/python3.8/site-packages/packaging/version.py in __init__(self, version)
273
274 # Validate the version and parse it into pieces
--> 275 match = self._regex.search(version)
276 if not match:
277 raise InvalidVersion("Invalid version: '{0}'".format(version))
TypeError: expected string or bytes-like object
Weird. Can you tell me what you get when you run anndata.__version__
? It worked fine over here.
import anndata as ad
ad.__version__
<Version('0.7.1')>
I am jusing jupter lab and casually copied the import as above (I don't know whether this will make a difference, not very versed in python).
Yep, I've been able to replicate and fix the issue. Hopefully. Grab 1.3.11 and confirm it's good now?
@ktpolanski It works well Thanks!
Ok, cool. Closing again :)
New versions of anndata/scanpy look for the
distances
andconnectivities
to be in adata.obsp instead of uns['neighbors']. Probably should update the outputs of bbknn to the adata.obsp as well.