Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for mus musculus descendant organisms #1248

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ components:
- # If organism is Mouse
rule:
column: organism_ontology_term_id
match_exact:
terms:
match_ancestors_inclusive:
ancestors:
- NCBITaxon:10090
error_message_suffix: >-
When 'organism_ontology_term_id' is 'NCBITaxon:10090' (Mus musculus), 'development_stage_ontology_term_id' MUST be the most accurate descendant of 'MmusDv:0000001' or unknown.
When 'organism_ontology_term_id' is 'NCBITaxon:10090' (Mus musculus) or one of its descendants, 'development_stage_ontology_term_id' MUST be the most accurate descendant of 'MmusDv:0000001' or unknown.
type: curie
curie_constraints:
ontologies:
Expand Down
7 changes: 7 additions & 0 deletions cellxgene_schema_cli/cellxgene_schema/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,16 @@ def _validate_column_dependencies(
terms_to_match = set()
column_to_match = dependency_def["rule"]["column"]
if "match_ancestors_inclusive" in dependency_def["rule"]:
print("rule", dependency_def["rule"])
ancestors = dependency_def["rule"]["match_ancestors_inclusive"]["ancestors"]
for ancestor in ancestors:
print("ancestor", ancestor)
term_descendants = ONTOLOGY_PARSER.get_term_descendants(ancestor, include_self=True)
print("term_descendants", term_descendants)
print("len(terms to match) before", len(terms_to_match))
terms_to_match.update(ONTOLOGY_PARSER.get_term_descendants(ancestor, include_self=True))
print("len(terms to match) after", len(terms_to_match))
print("terms to match", terms_to_match)
if "match_exact" in dependency_def["rule"]:
terms_to_match.update(dependency_def["rule"]["match_exact"]["terms"])
try:
Expand Down
2 changes: 1 addition & 1 deletion cellxgene_schema_cli/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
anndata==0.11.2
cellxgene-ontology-guide==1.4.1 # update before a schema migration
cellxgene-ontology-guide==1.4.2 # update before a schema migration
click<9
Cython<4
dask[array]==2024.12.0
Expand Down
19 changes: 19 additions & 0 deletions cellxgene_schema_cli/tests/test_schema_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,25 @@ def test_cell_type_ontology_term_id(self, validator_with_adata, term):
deprecated_error_message = f"ERROR: '{term}' in 'cell_type_ontology_term_id' is a deprecated term id of 'CL'."
assert not_allowed_error_message in validator.errors or deprecated_error_message in validator.errors

@pytest.mark.parametrize(
"organism_ontology_term_id",
[
"NCBITaxon:10090", # Mus musculus (ancestor term, always allowed)
"NCBITaxon:947985", # Mus musculus albula
"NCBITaxon:35531", # Mus musculus bactrianus
],
)
def test_development_stage_ontology_term_id_mouse_descendant(self, validator_with_adata, organism_ontology_term_id):
"""
If organism_ontolology_term_id is "NCBITaxon:10090" for Mus musculus OR its descendants,
this MUST be the most accurate MmusDv:0000001 descendant.
"""
validator = validator_with_adata
obs = validator.adata.obs
obs.loc[obs.index[1], "organism_ontology_term_id"] = organism_ontology_term_id
validator.validate_adata()
assert not validator.errors

@pytest.mark.parametrize(
"development_stage_ontology_term_id,error",
[
Expand Down
Loading