mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-02 02:38:11 +08:00
rename X_approx_distribution to X_approximate_distribution (#2337)
This commit is contained in:
@@ -151,8 +151,8 @@ def dataset_args(func):
|
||||
help="URL providing more information about the dataset (hint: must be a fully specified absolute URL).",
|
||||
)
|
||||
@click.option(
|
||||
"--X-approx-distribution",
|
||||
default=DEFAULT_CONFIG.dataset_config.X_approx_distribution,
|
||||
"--X-approximate-distribution",
|
||||
default=DEFAULT_CONFIG.dataset_config.X_approximate_distribution,
|
||||
show_default=True,
|
||||
type=click.Choice(["auto", "normal", "count"], case_sensitive=False),
|
||||
help="Specify the approximate distribution of X matrix values. 'auto' will use a heuristic "
|
||||
@@ -326,7 +326,7 @@ def launch(
|
||||
disable_diffexp,
|
||||
config_file,
|
||||
dump_default_config,
|
||||
x_approx_distribution,
|
||||
x_approximate_distribution,
|
||||
):
|
||||
"""Launch the cellxgene data viewer.
|
||||
This web app lets you explore single-cell expression data.
|
||||
@@ -385,7 +385,7 @@ def launch(
|
||||
embeddings__names=embedding,
|
||||
diffexp__enable=not disable_diffexp,
|
||||
diffexp__lfc_cutoff=diffexp_lfc_cutoff,
|
||||
X_approx_distribution=x_approx_distribution,
|
||||
X_approximate_distribution=x_approximate_distribution,
|
||||
)
|
||||
|
||||
diff = cli_config.server_config.changes_from_default()
|
||||
|
||||
@@ -38,7 +38,7 @@ class DatasetConfig(BaseConfig):
|
||||
self.diffexp__lfc_cutoff = default_config["diffexp"]["lfc_cutoff"]
|
||||
self.diffexp__top_n = default_config["diffexp"]["top_n"]
|
||||
|
||||
self.X_approx_distribution = default_config["X_approx_distribution"]
|
||||
self.X_approximate_distribution = default_config["X_approximate_distribution"]
|
||||
|
||||
except KeyError as e:
|
||||
raise ConfigurationError(f"Unexpected config: {str(e)}")
|
||||
@@ -52,7 +52,7 @@ class DatasetConfig(BaseConfig):
|
||||
self.handle_user_annotations(context)
|
||||
self.handle_embeddings()
|
||||
self.handle_diffexp(context)
|
||||
self.handle_X_approx_distribution()
|
||||
self.handle_X_approximate_distribution()
|
||||
|
||||
def get_data_adaptor(self):
|
||||
server_config = self.app_config.server_config
|
||||
@@ -186,9 +186,9 @@ class DatasetConfig(BaseConfig):
|
||||
"CAUTION: due to the size of your dataset, " "running differential expression may take longer or fail."
|
||||
)
|
||||
|
||||
def handle_X_approx_distribution(self):
|
||||
self.validate_correct_type_of_configuration_attribute("X_approx_distribution", str)
|
||||
if self.X_approx_distribution not in ["auto", "normal", "count"]:
|
||||
def handle_X_approximate_distribution(self):
|
||||
self.validate_correct_type_of_configuration_attribute("X_approximate_distribution", str)
|
||||
if self.X_approximate_distribution not in ["auto", "normal", "count"]:
|
||||
raise ConfigurationError(
|
||||
"X_approx_distribution has unknown value -- must be 'auto', 'normal' or 'count'."
|
||||
"X_approximate_distribution has unknown value -- must be 'auto', 'normal' or 'count'."
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ from scipy import sparse
|
||||
import backend.common.compute.diffexp_generic as diffexp_generic
|
||||
import backend.common.compute.estimate_distribution as estimate_distribution
|
||||
from backend.common.colors import convert_anndata_category_colors_to_cxg_category_colors
|
||||
from backend.common.constants import Axis, MAX_LAYOUTS, XApproxDistribution
|
||||
from backend.common.constants import Axis, MAX_LAYOUTS, XApproximateDistribution
|
||||
from backend.server.common.corpora import corpora_get_props_from_anndata
|
||||
from backend.common.errors import PrepareError, DatasetAccessError
|
||||
from backend.common.utils.type_conversion_utils import get_schema_type_hint_of_array
|
||||
@@ -29,7 +29,7 @@ class AnndataAdaptor(DataAdaptor):
|
||||
def __init__(self, data_locator, app_config=None, dataset_config=None):
|
||||
super().__init__(data_locator, app_config, dataset_config)
|
||||
self.data = None
|
||||
self.X_approx_distribution = None
|
||||
self.X_approximate_distribution = None
|
||||
self._load_data(data_locator)
|
||||
self._validate_and_initialize()
|
||||
|
||||
@@ -192,12 +192,12 @@ class AnndataAdaptor(DataAdaptor):
|
||||
self.gene_count = self.data.shape[1]
|
||||
self._create_schema()
|
||||
|
||||
if self.dataset_config.X_approx_distribution == "auto":
|
||||
if self.dataset_config.X_approximate_distribution == "auto":
|
||||
"""Lazy evaluate the heuristic if we are backed."""
|
||||
if not self.data.isbacked:
|
||||
self.X_approx_distribution = estimate_distribution.estimate_approximate_distribution(self.data.X)
|
||||
self.X_approximate_distribution = estimate_distribution.estimate_approximate_distribution(self.data.X)
|
||||
else:
|
||||
self.X_approx_distribution = self.dataset_config.X_approx_distribution
|
||||
self.X_approximate_distribution = self.dataset_config.X_approximate_distribution
|
||||
|
||||
# heuristic
|
||||
n_values = self.data.shape[0] * self.data.shape[1]
|
||||
@@ -331,15 +331,15 @@ class AnndataAdaptor(DataAdaptor):
|
||||
X = self.data.X[obs_mask, var_mask]
|
||||
return X
|
||||
|
||||
def get_X_approx_distribution(self) -> XApproxDistribution:
|
||||
def get_X_approximate_distribution(self) -> XApproximateDistribution:
|
||||
"""return the approximate distribution of the X matrix."""
|
||||
if self.X_approx_distribution is None:
|
||||
if self.X_approximate_distribution is None:
|
||||
"""Not yet evaluated."""
|
||||
assert(self.dataset_config.X_approx_distribution == "auto")
|
||||
assert(self.dataset_config.X_approximate_distribution == "auto")
|
||||
self.data = self.data.to_memory() # loads data
|
||||
self.X_approx_distribution = estimate_distribution.estimate_approximate_distribution(self.data.X)
|
||||
self.X_approximate_distribution = estimate_distribution.estimate_approximate_distribution(self.data.X)
|
||||
|
||||
return self.X_approx_distribution
|
||||
return self.X_approximate_distribution
|
||||
|
||||
def get_shape(self):
|
||||
return self.data.shape
|
||||
|
||||
@@ -6,7 +6,7 @@ from scipy import sparse
|
||||
from server_timing import Timing as ServerTiming
|
||||
|
||||
from backend.server.common.config.app_config import AppConfig
|
||||
from backend.common.constants import Axis, XApproxDistribution
|
||||
from backend.common.constants import Axis, XApproximateDistribution
|
||||
from backend.common.errors import FilterError, JSONEncodingValueError, ExceedsLimitError, UnsupportedSummaryMethod
|
||||
from backend.common.utils.utils import jsonify_numpy
|
||||
from backend.common.fbs.matrix import encode_matrix_fbs
|
||||
@@ -72,9 +72,9 @@ class DataAdaptor(metaclass=ABCMeta):
|
||||
the return type is either ndarray or scipy.sparse.spmatrix."""
|
||||
pass
|
||||
|
||||
def get_X_approx_distribution(self) -> XApproxDistribution:
|
||||
def get_X_approximate_distribution(self) -> XApproximateDistribution:
|
||||
"""return the approximate distribution of the X matrix."""
|
||||
return XApproxDistribution.NORMAL
|
||||
return XApproximateDistribution.NORMAL
|
||||
|
||||
@abstractmethod
|
||||
def get_shape(self):
|
||||
|
||||
@@ -77,7 +77,7 @@ dataset:
|
||||
lfc_cutoff: 0.01
|
||||
top_n: 10
|
||||
|
||||
X_approx_distribution: auto
|
||||
X_approximate_distribution: auto
|
||||
|
||||
external:
|
||||
# You can retrieve configuration parameters from this config file, the environment,
|
||||
|
||||
Reference in New Issue
Block a user