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
+5 -7
View File
@@ -1,7 +1,6 @@
import warnings
import numpy as np
import pandas as pd
from pandas.core.dtypes.dtypes import CategoricalDtype
import anndata
from scipy import sparse
@@ -314,16 +313,15 @@ class AnndataAdaptor(DataAdaptor):
raise FilterError("Error parsing filter")
with ServerTiming.time("layout.compute"):
X_umap = scanpy_umap(self.data, obs_mask)
normalized_layout = DataAdaptor.normalize_embedding(X_umap)
# Server picks reemedding name, which must not collide with any other
# embedding name generated by this backed.
# embedding name generated by this backend.
name = f"reembed:{method}_{datetime.now().isoformat(timespec='milliseconds')}"
dims = [f"{name}_0", f"{name}_1"]
df = pd.DataFrame(normalized_layout, columns=dims)
fbs = encode_matrix_fbs(df, col_idx=df.columns, row_idx=None)
schema = {"name": name, "type": "float32", "dims": dims}
return (schema, fbs)
layout_schema = {"name": name, "type": "float32", "dims": dims}
self.schema["layout"]["obs"].append(layout_schema)
self.data.obsm[f"X_{name}"] = X_umap
return layout_schema
def compute_diffexp_ttest(self, maskA, maskB, top_n=None, lfc_cutoff=None):
if top_n is None: