From 29e93560f166dc83a1c7d3abc22f7d69d0df032c Mon Sep 17 00:00:00 2001 From: Carlos Loucera Date: Fri, 30 Jun 2023 09:52:59 +0200 Subject: [PATCH 1/5] Update error message. --- drexml/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drexml/utils.py b/drexml/utils.py index 09da8e7..aba2fa4 100644 --- a/drexml/utils.py +++ b/drexml/utils.py @@ -50,7 +50,7 @@ def check_cli_arg_is_bool(arg): elif arg in ["false", "False", "FALSE", "0"]: arg = False else: - raise ValueError("debug must be a boolean") + raise ValueError(f"argument {arg} must be a boolean") return arg From f9f9753ebcceae7e926bf38791968f8d1c40b0af Mon Sep 17 00:00:00 2001 From: Carlos Loucera Date: Fri, 30 Jun 2023 09:55:06 +0200 Subject: [PATCH 2/5] Fix variable names. --- drexml/explain.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drexml/explain.py b/drexml/explain.py index ca12820..2c14ee1 100644 --- a/drexml/explain.py +++ b/drexml/explain.py @@ -12,35 +12,39 @@ from drexml.pystab import nogueria_test -def matcorr(O, P): +def matcorr(features, targets): """Fast correlation matrix computation. Parameters ---------- - O : ndarray + features : ndarray [n_samples, n_features] A matrix of observations. - P : ndarray + targets : ndarray [n_samples, n_tasks] A matrix of predictions. Returns ------- ndarray - The cross-correlation matrix. + The correlation matrix. """ - n = O.shape[0] + n = features.shape[0] - DO = O - ( - np.einsum("nt->t", O, optimize="optimal") / np.double(n) - ) # compute O - mean(O) - DP = P - ( - np.einsum("nm->m", P, optimize="optimal") / np.double(n) - ) # compute P - mean(P) + features_center = features - ( + np.einsum("nt->t", features, optimize="optimal") / np.double(n) + ) + targets_center = targets - ( + np.einsum("nm->m", targets, optimize="optimal") / np.double(n) + ) - cov = np.einsum("nm,nt->mt", DP, DO, optimize="optimal") + cov = np.einsum("nm,nt->mt", targets_center, features_center, optimize="optimal") - varP = np.einsum("nm,nm->m", DP, DP, optimize="optimal") - varO = np.einsum("nt,nt->t", DO, DO, optimize="optimal") - tmp = np.einsum("m,t->mt", varP, varO, optimize="optimal") + targets_var = np.einsum( + "nm,nm->m", targets_center, targets_center, optimize="optimal" + ) + features_var = np.einsum( + "nt,nt->t", features_center, features_center, optimize="optimal" + ) + tmp = np.einsum("m,t->mt", targets_var, features_var, optimize="optimal") return cov / np.sqrt(tmp) From bea1a37fcf0d160c6014fe02d491e6ec0af1b93f Mon Sep 17 00:00:00 2001 From: Carlos Loucera Date: Fri, 30 Jun 2023 09:55:56 +0200 Subject: [PATCH 3/5] Remove redundant args and fix docs. --- drexml/datasets.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drexml/datasets.py b/drexml/datasets.py index 8cc4abb..bd2fd3a 100644 --- a/drexml/datasets.py +++ b/drexml/datasets.py @@ -23,29 +23,30 @@ def load_physiological_circuits(): return circuit_names.index[circuit_names["is_physiological"]].tolist() -def fetch_file(disease, key, env, version="latest"): - """ - Retrieve data. - - Parameters: +def fetch_file(key, env, version="latest"): + """Retrieve file from the environment. - - disease (str): The name of the disease. - - key (str): The key associated with the data. - - env (Union[str, pathlib.Path]): The environment variable or path containing the data. - - version (str, optional): The version of the data to retrieve (default: "latest"). - - debug (bool, optional): Whether to enable debug mode (default: False). - - Returns: - - frame (np.ndarray): The preprocessed data frame. + Parameters + ---------- + key : str + Key of the file to retrieve. + env : dict + Environment. + version : str + Version of the file to retrieve. - Raises: - - ConnectTimeout: If a connection timeout occurs during retrieval. + Returns + ------- + pathlib.Path + Path to the file. + Raises + ------ + NotImplementedError + Not implemented yet. """ print(f"Retrieving {key}") - experiment_env_path = pathlib.Path(disease) - env = read_disease_config(experiment_env_path) if env[key + "_zenodo"]: # pragma: no cover if version == "latest": try: @@ -352,10 +353,10 @@ def get_disease_data(disease): experiment_env_path = pathlib.Path(disease) env = read_disease_config(experiment_env_path) - gene_exp = fetch_file(disease, key="gene_exp", env=env, version="latest") - pathvals = fetch_file(disease, key="pathvals", env=env, version="latest") - circuits = fetch_file(disease, key="circuits", env=env, version="latest") - genes = fetch_file(disease, key="genes", env=env, version="latest") + gene_exp = fetch_file(key="gene_exp", env=env, version="latest") + pathvals = fetch_file(key="pathvals", env=env, version="latest") + circuits = fetch_file(key="circuits", env=env, version="latest") + genes = fetch_file(key="genes", env=env, version="latest") # gene_exp = gene_exp[genes.index[genes[genes_column]]] From 5b6f92792649916a5ae9afd2a8e257548f98dc84 Mon Sep 17 00:00:00 2001 From: Carlos Loucera Date: Fri, 30 Jun 2023 12:23:28 +0200 Subject: [PATCH 4/5] Update installation method. --- docs/source/index.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 922fe19..454b388 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,12 +12,11 @@ and signaling circuits. Installation ============= -You can install drexml from PyPI using pip: +You can install drexml using: .. code:: - pip install git+ssh://git@github.com:loucerac/drexml.git - + pip install git+https://github.com/loucerac/drexml.git@master Getting started From f51c7fb0338c6e9ca6dc09e6438f76aa56185819 Mon Sep 17 00:00:00 2001 From: Carlos Loucera Date: Fri, 30 Jun 2023 12:25:19 +0200 Subject: [PATCH 5/5] Update version. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index caa605b..ee34af7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "drexml" -version = "0.9.11" +version = "0.9.12" description = "(DRExM³L) Drug REpurposing using and eXplainable Machine Learning and Mechanistic Models of signal transduction\"" authors = [ "Carlos Loucera ",