From 6de64f64ab00c995cc067b786eb418d35ecea725 Mon Sep 17 00:00:00 2001 From: Evan Molinelli Date: Fri, 6 Dec 2024 16:49:20 -0500 Subject: [PATCH] feat: X_{suffix} to include descendants of Visium (#1144) Co-authored-by: Evan Molinelli --- .../tests/test_schema_compliance.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/cellxgene_schema_cli/tests/test_schema_compliance.py b/cellxgene_schema_cli/tests/test_schema_compliance.py index aa69890e..85baab4b 100644 --- a/cellxgene_schema_cli/tests/test_schema_compliance.py +++ b/cellxgene_schema_cli/tests/test_schema_compliance.py @@ -2436,7 +2436,10 @@ def test_obsm_values_nan(self, validator_with_visium_assay, key): assert validator.errors == ["ERROR: adata.obs['spatial] contains at least one NaN value."] def test_obsm_values_no_X_embedding__non_spatial_dataset(self, validator_with_adata): - validator = validator_with_adata + """ + X_{suffix} embeddings MUST exist for non-spatial datasets + """ + validator: Validator = validator_with_adata validator.adata.obsm["harmony"] = validator.adata.obsm["X_umap"] validator.adata.uns["default_embedding"] = "harmony" del validator.adata.obsm["X_umap"] @@ -2451,14 +2454,27 @@ def test_obsm_values_no_X_embedding__non_spatial_dataset(self, validator_with_ad "WARNING: Validation of raw layer was not performed due to current errors, try again after fixing current errors.", ] - def test_obsm_values_no_X_embedding__visium_dataset(self, validator_with_visium_assay): - validator = validator_with_visium_assay + @pytest.mark.parametrize("assay_ontology_term_id", ["EFO:0010961", "EFO:0030062", "EFO:0022860"]) + def test_obsm_values_no_X_embedding__visium_dataset(self, validator_with_visium_assay, assay_ontology_term_id): + """ + X_{suffix} embeddings MAY exist for spatial datasets + """ + validator: Validator = validator_with_visium_assay validator.adata.uns["default_embedding"] = "spatial" - del validator.adata.obsm["X_umap"] - validator.reset(None, 2) - validator.validate_adata() + validator.adata.obs["assay_ontology_term_id"] = assay_ontology_term_id + + # may have X_{suffix} embedding + validator._validate_obsm() + assert validator.is_spatial is True assert validator.errors == [] + validator.reset() + + # may also have no X_{suffix} embedding + del validator.adata.obsm["X_umap"] + validator._validate_obsm() assert validator.is_spatial is True + assert validator.errors == [] + validator.reset() def test_obsm_values_no_X_embedding__slide_seq_v2_dataset(self, validator_with_slide_seq_v2_assay): validator = validator_with_slide_seq_v2_assay