Skip to content

Commit

Permalink
Merge pull request #13 from hubmapconsortium/popv
Browse files Browse the repository at this point in the history
added support for HuBMAP data
  • Loading branch information
axdanbol authored Nov 6, 2023
2 parents b545052 + e8b15b6 commit 3ac1f97
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions containers/popv/context/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -140,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

Expand All @@ -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:
Expand Down

0 comments on commit 3ac1f97

Please sign in to comment.