From 4f2d1c3e6869124e0764644c04b36ba17b350c07 Mon Sep 17 00:00:00 2001 From: Vicky Daiya Date: Mon, 6 Nov 2023 15:47:53 -0500 Subject: [PATCH 1/2] handles non integer X matrix --- containers/popv/context/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/containers/popv/context/main.py b/containers/popv/context/main.py index d027997..746a648 100644 --- a/containers/popv/context/main.py +++ b/containers/popv/context/main.py @@ -62,12 +62,16 @@ def prepare_query( model_path = self.find_model_dir(options["models_dir"], organ) reference_data = scanpy.read_h5ad(reference_data_path) n_samples_per_label = self.get_n_samples_per_label(reference_data, options) - data, var_names = self.normalize_var_names(data, options) + data = self.normalize_var_names(data, options) if options["query_layers_key"] == "raw": options["query_layers_key"] = None data.X = data.raw.X + if options["query_layers_key"] == "X": + options["query_layers_key"] = None + data.X = numpy.rint(data.X) + data = self.add_model_genes(data, model_path, options["query_layers_key"]) data.var_names_make_unique() @@ -149,7 +153,7 @@ def getNewName(name: str): return lookup.get(key, name) data.var_names = t.cast(t.Any, names.map(getNewName)) - return data, names + return data def load_ensemble_lookup(self, options: PopvOptions): with open(options["ensemble_lookup"]) as file: From e8b15b6c89ed2457ea9b0ed1c237f42b370554ce Mon Sep 17 00:00:00 2001 From: Vicky Daiya Date: Mon, 6 Nov 2023 15:50:55 -0500 Subject: [PATCH 2/2] minor changes --- containers/popv/context/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/containers/popv/context/main.py b/containers/popv/context/main.py index 746a648..9b2dcf7 100644 --- a/containers/popv/context/main.py +++ b/containers/popv/context/main.py @@ -144,7 +144,7 @@ def _find_in_dir( def normalize_var_names( self, data: scanpy.AnnData, options: PopvOptions - ) -> t.Tuple[scanpy.AnnData, pandas.Index]: + ) -> scanpy.AnnData: lookup = self.load_ensemble_lookup(options) names = data.var_names