mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 19:48:11 +08:00
remove experimental ontology support (#2300)
* remove experimental ontology support * lint * remove ontologies from unit tests * additional test changes
This commit is contained in:
@@ -44,20 +44,6 @@ def annotation_args(func):
|
||||
help="Directory of where to save output annotations; filename will be specified in the application. "
|
||||
"Incompatible with --annotations-file and --gene-sets-file.",
|
||||
)
|
||||
@click.option(
|
||||
"--experimental-annotations-ontology",
|
||||
is_flag=True,
|
||||
default=DEFAULT_CONFIG.dataset_config.user_annotations__ontology__enable,
|
||||
show_default=True,
|
||||
help="When creating annotations, optionally autocomplete names from ontology terms.",
|
||||
)
|
||||
@click.option(
|
||||
"--experimental-annotations-ontology-obo",
|
||||
default=DEFAULT_CONFIG.dataset_config.user_annotations__ontology__obo_location,
|
||||
show_default=True,
|
||||
metavar="<path or url>",
|
||||
help="Location of OBO file defining cell annotation autosuggest terms.",
|
||||
)
|
||||
@click.option(
|
||||
"--disable-gene-sets-save",
|
||||
is_flag=True,
|
||||
@@ -338,8 +324,6 @@ def launch(
|
||||
disable_gene_sets_save,
|
||||
backed,
|
||||
disable_diffexp,
|
||||
experimental_annotations_ontology,
|
||||
experimental_annotations_ontology_obo,
|
||||
experimental_enable_reembedding,
|
||||
config_file,
|
||||
dump_default_config,
|
||||
@@ -396,8 +380,6 @@ def launch(
|
||||
user_annotations__local_file_csv__directory=user_generated_data_dir,
|
||||
user_annotations__local_file_csv__gene_sets_file=gene_sets_file,
|
||||
user_annotations__gene_sets__readonly=disable_gene_sets_save,
|
||||
user_annotations__ontology__enable=experimental_annotations_ontology,
|
||||
user_annotations__ontology__obo_location=experimental_annotations_ontology_obo,
|
||||
presentation__max_categories=max_category_items,
|
||||
presentation__custom_colors=not disable_custom_colors,
|
||||
embeddings__names=embedding,
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import fastobo
|
||||
import fsspec
|
||||
|
||||
from backend.common.errors import OntologyLoadFailure, DisabledFeatureError
|
||||
from backend.common.errors import DisabledFeatureError
|
||||
from backend.common.utils.type_conversion_utils import get_schema_type_hint_of_array
|
||||
from backend.common.genesets import write_gene_sets_tidycsv
|
||||
|
||||
|
||||
class Annotations(metaclass=ABCMeta):
|
||||
""" baseclass for annotations, including ontologies and gene sets"""
|
||||
|
||||
""" our default ontology is the PURL for the Cell Ontology.
|
||||
See http://www.obofoundry.org/ontology/cl.html """
|
||||
DefaultOnotology = "http://purl.obolibrary.org/obo/cl.obo"
|
||||
"""baseclass for annotations and gene sets"""
|
||||
|
||||
def __init__(self, config={}):
|
||||
self.ontology_data = None
|
||||
self.config = config
|
||||
|
||||
def user_annotations_enabled(self):
|
||||
@@ -33,27 +25,6 @@ class Annotations(metaclass=ABCMeta):
|
||||
if not self.gene_sets_save_enabled():
|
||||
raise DisabledFeatureError("User gene sets save is disabled.")
|
||||
|
||||
def load_ontology(self, path):
|
||||
"""Load and parse ontologies - currently support OBO files only."""
|
||||
if path is None:
|
||||
path = self.DefaultOnotology
|
||||
|
||||
try:
|
||||
with fsspec.open(path) as f:
|
||||
obo = fastobo.iter(f)
|
||||
terms = filter(lambda stanza: type(stanza) is fastobo.term.TermFrame, obo)
|
||||
names = [tag.name for term in terms for tag in term if type(tag) is fastobo.term.NameClause]
|
||||
self.ontology_data = names
|
||||
|
||||
except FileNotFoundError as e:
|
||||
raise OntologyLoadFailure("Unable to find OBO ontology path") from e
|
||||
|
||||
except SyntaxError as e:
|
||||
raise OntologyLoadFailure("Syntax error loading OBO ontology") from e
|
||||
|
||||
except Exception as e:
|
||||
raise OntologyLoadFailure("Error loading OBO file") from e
|
||||
|
||||
def get_schema(self, data_adaptor):
|
||||
schema = []
|
||||
labels = self.read_labels(data_adaptor)
|
||||
@@ -82,7 +53,7 @@ class Annotations(metaclass=ABCMeta):
|
||||
|
||||
@abstractmethod
|
||||
def read_gene_sets(self, data_adaptor):
|
||||
"""Return the gene sets from persistent storage """
|
||||
"""Return the gene sets from persistent storage"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -193,14 +193,14 @@ class AnnotationsLocalFile(Annotations):
|
||||
return os.getcwd()
|
||||
|
||||
def _get_celllabels_filename(self, data_adaptor):
|
||||
""" return the current annotation file name """
|
||||
"""return the current annotation file name"""
|
||||
if self.label_output_file:
|
||||
return self.label_output_file
|
||||
|
||||
return self._get_filename(data_adaptor, "cell-labels")
|
||||
|
||||
def _get_genesets_filename(self, data_adaptor):
|
||||
""" return the current gene sets file name """
|
||||
"""return the current gene sets file name"""
|
||||
if self.gene_sets_output_file:
|
||||
return self.gene_sets_output_file
|
||||
|
||||
@@ -263,12 +263,6 @@ class AnnotationsLocalFile(Annotations):
|
||||
params["annotations_genesets_name_is_read_only"] = self.gene_sets_output_file is not None
|
||||
params["user_annotation_collection_name_enabled"] = True
|
||||
|
||||
if self.ontology_data:
|
||||
params["annotations_cell_ontology_enabled"] = True
|
||||
params["annotations_cell_ontology_terms"] = self.ontology_data
|
||||
else:
|
||||
params["annotations_cell_ontology_enabled"] = False
|
||||
|
||||
if self.label_output_file is not None:
|
||||
# user has hard-wired the name of the annotation cell label data collection
|
||||
fname = os.path.basename(self.label_output_file)
|
||||
|
||||
@@ -47,9 +47,6 @@ def get_client_config(app_config, data_adaptor):
|
||||
"annotations_genesets": True, # feature flag
|
||||
"annotations_genesets_readonly": dataset_config.user_annotations__gene_sets__readonly,
|
||||
"annotations_genesets_summary_methods": ["mean"],
|
||||
"annotations_cell_ontology_enabled": False,
|
||||
"annotations_cell_ontology_obopath": None,
|
||||
"annotations_cell_ontology_terms": None,
|
||||
"custom_colors": dataset_config.presentation__custom_colors,
|
||||
"diffexp-may-be-slow": False,
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ from os.path import splitext, isdir
|
||||
|
||||
from backend.server.common.annotations.local_file_csv import AnnotationsLocalFile
|
||||
from backend.server.common.config.base_config import BaseConfig
|
||||
from backend.common.errors import ConfigurationError, OntologyLoadFailure, AnnotationsError
|
||||
from backend.common.errors import ConfigurationError, AnnotationsError
|
||||
from backend.server.compute.scanpy import get_scanpy_module
|
||||
from backend.server.data_common.matrix_loader import MatrixDataLoader
|
||||
|
||||
@@ -28,10 +28,6 @@ class DatasetConfig(BaseConfig):
|
||||
"directory"
|
||||
]
|
||||
self.user_annotations__local_file_csv__file = default_config["user_annotations"]["local_file_csv"]["file"]
|
||||
self.user_annotations__ontology__enable = default_config["user_annotations"]["ontology"]["enable"]
|
||||
self.user_annotations__ontology__obo_location = default_config["user_annotations"]["ontology"][
|
||||
"obo_location"
|
||||
]
|
||||
self.user_annotations__gene_sets__readonly = default_config["user_annotations"]["gene_sets"]["readonly"]
|
||||
self.user_annotations__local_file_csv__gene_sets_file = default_config["user_annotations"][
|
||||
"local_file_csv"
|
||||
@@ -101,10 +97,6 @@ class DatasetConfig(BaseConfig):
|
||||
self.validate_correct_type_of_configuration_attribute(
|
||||
"user_annotations__local_file_csv__gene_sets_file", (type(None), str)
|
||||
)
|
||||
self.validate_correct_type_of_configuration_attribute("user_annotations__ontology__enable", bool)
|
||||
self.validate_correct_type_of_configuration_attribute(
|
||||
"user_annotations__ontology__obo_location", (type(None), str)
|
||||
)
|
||||
self.validate_correct_type_of_configuration_attribute("user_annotations__gene_sets__readonly", bool)
|
||||
|
||||
if self.user_annotations__enable or not self.user_annotations__gene_sets__readonly:
|
||||
@@ -122,13 +114,6 @@ class DatasetConfig(BaseConfig):
|
||||
else:
|
||||
raise ConfigurationError('The only annotation type support is "local_file_csv"')
|
||||
|
||||
if self.user_annotations__enable:
|
||||
if self.user_annotations__ontology__enable or self.user_annotations__ontology__obo_location:
|
||||
try:
|
||||
self.user_annotations.load_ontology(self.user_annotations__ontology__obo_location)
|
||||
except OntologyLoadFailure as e:
|
||||
raise ConfigurationError("Unable to load ontology terms\n" + str(e))
|
||||
|
||||
self.check_annotation_config_vars_not_set(context)
|
||||
|
||||
def handle_local_file_csv_annotations(self, context):
|
||||
@@ -183,14 +168,6 @@ class DatasetConfig(BaseConfig):
|
||||
if not self.user_annotations__enable:
|
||||
if filename is not None:
|
||||
context["messagefn"]("Warning: --annotations-file ignored as annotations are disabled.")
|
||||
if self.user_annotations__ontology__enable:
|
||||
context["messagefn"](
|
||||
"Warning: --experimental-annotations-ontology ignored as annotations are disabled."
|
||||
)
|
||||
if self.user_annotations__ontology__obo_location is not None:
|
||||
context["messagefn"](
|
||||
"Warning: --experimental-annotations-ontology-obo ignored as annotations are disabled."
|
||||
)
|
||||
if dirname is not None:
|
||||
context["messagefn"]("Warning: --user-generated-data-dir ignored as annotations are disabled.")
|
||||
|
||||
|
||||
@@ -66,9 +66,6 @@ dataset:
|
||||
directory: null
|
||||
file: null # annotations file name
|
||||
gene_sets_file: null # gene sets file name
|
||||
ontology:
|
||||
enable: false
|
||||
obo_location: null
|
||||
gene_sets:
|
||||
readonly: false # gene sets CRUD enabled/disabled
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
anndata>=0.7.0
|
||||
boto3>=1.12.18
|
||||
click>=7.1.2
|
||||
fastobo>=0.6.1
|
||||
Flask>=1.0.2,<2.0.0 # Flask 2.0 is not compatible with the latest version of Flask-RESTful (0.3.8)
|
||||
Flask-Compress>=1.4.0
|
||||
Flask-Cors>=3.0.9 # CVE-2020-25032
|
||||
|
||||
Reference in New Issue
Block a user