diff options
author | Frederick Muriuki Muriithi | 2022-05-24 04:46:57 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-05-24 05:16:55 +0300 |
commit | 36f8421a8fe223189ab88ee1df3923719ffa4fc0 (patch) | |
tree | 7f79b4f594ec787190c9a7c7dcbdd4bec40a0db1 /gn3 | |
parent | 63d9c9932721e98a9d6715686214157e276af105 (diff) | |
download | genenetwork3-36f8421a8fe223189ab88ee1df3923719ffa4fc0.tar.gz |
New script to compute partial correlations
* Add a new script to compute the partial correlations against:
- a select list of traits, or
- an entire dataset
depending on the specified subcommand. This new script is meant to supercede
the `scripts/partial_correlations.py` script.
* Fix the check for errors
* Reorganise the order of arguments for the
`partial_correlations_with_target_traits` function: move the `method`
argument before the `target_trait_names` argument so that the common
arguments in the partial correlation computation functions share the same
order.
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/api/correlation.py | 4 | ||||
-rw-r--r-- | gn3/computations/partial_correlations.py | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py index 5f2d486..3aadcb9 100644 --- a/gn3/api/correlation.py +++ b/gn3/api/correlation.py @@ -148,8 +148,8 @@ def partial_correlation(): trait_fullname(args["primary_trait"]), tuple( trait_fullname(trait) for trait in args["control_traits"]), + args["method"], tuple( - trait_fullname(trait) for trait in args["target_traits"]), - args["method"]) + trait_fullname(trait) for trait in args["target_traits"])) return build_response({"status": "success", "results": results}) diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py index 530dd71..f316f67 100644 --- a/gn3/computations/partial_correlations.py +++ b/gn3/computations/partial_correlations.py @@ -681,7 +681,7 @@ def partial_correlations_with_target_db(# pylint: disable=[R0913, R0914, R0911] check_res = check_for_common_errors( conn, primary_trait_name, control_trait_names, threshold) - if check_res.get("status") == "error": + if check_res.get("status") != "success": return check_res primary_trait = check_res["primary_trait"] @@ -819,15 +819,15 @@ def partial_correlations_with_target_db(# pylint: disable=[R0913, R0914, R0911] def partial_correlations_with_target_traits( conn: Any, primary_trait_name: str, - control_trait_names: Tuple[str, ...], - target_trait_names: Tuple[str, ...], method: str) -> dict: + control_trait_names: Tuple[str, ...], method: str, + target_trait_names: Tuple[str, ...]) -> dict: """ Compute partial correlation against a specific selection of traits. """ threshold = 0 check_res = check_for_common_errors( conn, primary_trait_name, control_trait_names, threshold) - if check_res.get("status") == "error": + if check_res.get("status") != "success": return check_res target_traits = { |