Skip to content

Commit

Permalink
adding better bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jkobject committed Feb 10, 2025
1 parent 5856b46 commit 4620575
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies = [
"lamindb[bionty,ourprojects,jupyter,cellregistry,zarr]>=1.0.4,<2",
"cellxgene-census>=0.1.0",
"torch==2.2.0",
"lightning>=2.0.0",
"lightning>=2.3.0",
"anndata>=0.9.0",
"zarr>=2.10.0",
"matplotlib>=3.5.0",
Expand Down
13 changes: 13 additions & 0 deletions scdataloader/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def __init__(
"""
Initializes the preprocessor and configures the workflow steps.
Your dataset should contain at least the following obs:
- `organism_ontology_term_id` with the ontology id of the organism of your anndata
- gene names in the `var.index` field of your anndata that map to the ensembl_gene nomenclature
or the hugo gene symbols nomenclature (if the later, set `is_symbol` to True)
Args:
filter_gene_by_counts (int or bool, optional): Determines whether to filter genes by counts.
If int, filters genes with counts. Defaults to False.
Expand Down Expand Up @@ -130,6 +135,14 @@ def __init__(
self.keepdata = keepdata

def __call__(self, adata, dataset_id=None) -> AnnData:
if "organism_ontology_term_id" not in adata[0].obs.columns:
raise ValueError(
"organism_ontology_term_id not found in adata.obs, you need to add an ontology term id for the organism of your anndata"
)
if not adata[0].var.index.str.contains("ENS").any() and not self.is_symbol:
raise ValueError(
"gene names in the `var.index` field of your anndata should map to the ensembl_gene nomenclature else set `is_symbol` to True if using hugo symbols"
)
if adata[0].obs.organism_ontology_term_id.iloc[0] not in self.organisms:
raise ValueError(
"we cannot work with this organism",
Expand Down

0 comments on commit 4620575

Please sign in to comment.