re-implement re-embeddings (#1679)

* fix mispelling

* re-implement re-embedding

* always load base embedding to fetch counts

* format

* lint

* fix tests

* lint

* fix accept handling

* test log

* more debug

* more

* more

* more

* more

* remove logging

* logging

* jsonify

* remove debugging logs

* lint

* clean up errors a bit

* fix issue found in PR review

* PR review changes
This commit is contained in:
Bruce Martin
2020-07-30 12:31:36 -07:00
committed by GitHub
parent bd147abb3f
commit 75cb513dd9
18 changed files with 225 additions and 179 deletions
+7 -3
View File
@@ -1,4 +1,5 @@
import importlib
import numpy as np
"""
Wrapper for various scanpy modules. Will raise NotImplementedError if the scanpy
@@ -11,8 +12,8 @@ def get_scanpy_module():
sc = importlib.import_module("scanpy")
# Future: we could enforce versions here, eg, lookat sc.__version__
return sc
except ModuleNotFoundError:
raise NotImplementedError("Please install scanpy to enable UMAP re-embedding")
except ModuleNotFoundError as e:
raise NotImplementedError("Please install scanpy to enable UMAP re-embedding") from e
except Exception as e:
# will capture other ImportError corner cases
raise NotImplementedError() from e
@@ -46,4 +47,7 @@ def scanpy_umap(adata, obs_mask=None, pca_options={}, neighbors_options={}, umap
sc.pp.neighbors(adata, **neighbors_options)
sc.tl.umap(adata, **umap_options)
return adata.obsm["X_umap"]
umap = adata.obsm["X_umap"]
result = np.full((obs_mask.shape[0], umap.shape[1]), np.NaN)
result[obs_mask] = umap
return result