aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-12-17 16:56:57 +0300
committerFrederick Muriuki Muriithi2021-12-17 16:56:57 +0300
commita9c760f1125423efd5b5a8e9f85ea84d23f10a11 (patch)
tree75ecd1b58582075c6d3589d1733b97d2b457e215 /gn3
parented87184929eec6614c2cca0105c335ad24bf2720 (diff)
downloadgenenetwork3-a9c760f1125423efd5b5a8e9f85ea84d23f10a11.tar.gz
Add API endpoint for partial correlations
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Add an API endpoint for the partial correlation.
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/correlation.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py
index 46121f8..e936eaf 100644
--- a/gn3/api/correlation.py
+++ b/gn3/api/correlation.py
@@ -8,6 +8,7 @@ from gn3.computations.correlations import compute_all_lit_correlation
from gn3.computations.correlations import compute_tissue_correlation
from gn3.computations.correlations import map_shared_keys_to_values
from gn3.db_utils import database_connector
+from gn3.computations.partial_correlations import partial_correlations_entry
correlation = Blueprint("correlation", __name__)
@@ -83,3 +84,18 @@ def compute_tissue_corr(corr_method="pearson"):
corr_method=corr_method)
return jsonify(results)
+
+@correlation.route("/partial", methods=["POST"])
+def partial_correlation():
+ def trait_fullname(trait):
+ return f"{trait['dataset']}::{trait['name']}"
+
+ args = request.get_json()
+ conn, _cursor_object = database_connector()
+ corr_results = partial_correlations_entry(
+ conn, trait_fullname(args["primary_trait"]),
+ tuple(trait_fullname(trait) for trait in args["control_traits"]),
+ args["method"], int(args["criteria"]), args["target_db"])
+ return make_response(
+ jsonify(corr_results),
+ 400)