Skip to content

Commit

Permalink
Merge pull request #33 from YosefLab/main
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
canergen authored Dec 10, 2023
2 parents 3074bcc + 949c903 commit 000e342
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion popv/algorithms/_onclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(
batch_key: str | None = "_batch_annotation",
labels_key: str | None = "_labels_annotation",
layers_key: str | None = None,
max_iter: Optionalint] = 30,
max_iter: int | None = 30,
cell_ontology_obs_key: str | None = None,
result_key: str | None = "popv_onclass_prediction",
seen_result_key: str | None = "popv_onclass_seen",
Expand Down
16 changes: 8 additions & 8 deletions popv/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,20 @@ def __init__(
f"{self.cl_obo_file} doesn't exist. Check that folder exists."
) from FileNotFoundError

self.check_validity_anndata(self.query_adata, "query")
self.setup_dataset(self.query_adata, "query", add_meta="_query")
self._check_validity_anndata(self.query_adata, "query")
self._setup_dataset(self.query_adata, "query", add_meta="_query")

if self.prediction_mode != "fast":
if self.genes:
self.ref_adata = ref_adata[:, self.genes].copy()
else:
self.ref_adata = ref_adata.copy()
self.setup_dataset(self.ref_adata, "reference")
self.check_validity_anndata(self.ref_adata, "reference")
self._setup_dataset(self.ref_adata, "reference")
self._check_validity_anndata(self.ref_adata, "reference")

self.preprocess()
self._preprocess()

def check_validity_anndata(self, adata, input_type):
def _check_validity_anndata(self, adata, input_type):
assert check_nonnegative_integers(
adata.X
), f"Make sure input {input_type} adata contains raw_counts"
Expand All @@ -230,7 +230,7 @@ def check_validity_anndata(self, adata, input_type):
assert adata.n_obs > 0, f"{input_type} anndata has no cells."
assert adata.n_vars > 0, f"{input_type} anndata has no genes."

def setup_dataset(self, adata, key, add_meta=""):
def _setup_dataset(self, adata, key, add_meta=""):
if isinstance(self.batch_key[key], list):
adata.obs["_batch_annotation"] = (
adata.obs[self.batch_key[key]].astype(str).sum(1).astype("category")
Expand Down Expand Up @@ -268,7 +268,7 @@ def setup_dataset(self, adata, key, add_meta=""):
else:
adata.obs["_ref_subsample"] = False

def preprocess(self):
def _preprocess(self):
if self.genes is None:
self.ref_adata = self.ref_adata[
:, np.intersect1d(self.ref_adata.var_names, self.query_adata.var_names)
Expand Down

0 comments on commit 000e342

Please sign in to comment.