aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/correlation.py4
-rw-r--r--gn3/computations/correlations.py26
2 files changed, 17 insertions, 13 deletions
diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py
index e7e89cf..a3e366e 100644
--- a/gn3/api/correlation.py
+++ b/gn3/api/correlation.py
@@ -5,7 +5,7 @@ from flask import request
from gn3.computations.correlations import compute_all_sample_correlation
from gn3.computations.correlations import compute_all_lit_correlation
-from gn3.computations.correlations import compute_all_tissue_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
@@ -78,7 +78,7 @@ def compute_tissue_corr(corr_method="pearson"):
primary_tissue_dict = tissue_input_data["primary_tissue"]
target_tissues_dict = tissue_input_data["target_tissues_dict"]
- results = compute_all_tissue_correlation(primary_tissue_dict=primary_tissue_dict,
+ results = compute_tissue_correlation(primary_tissue_dict=primary_tissue_dict,
target_tissues_data=target_tissues_dict,
corr_method=corr_method)
diff --git a/gn3/computations/correlations.py b/gn3/computations/correlations.py
index 56f483c..1fd3213 100644
--- a/gn3/computations/correlations.py
+++ b/gn3/computations/correlations.py
@@ -124,11 +124,12 @@ def filter_shared_sample_keys(this_samplelist,
return (this_vals, target_vals)
-def compute_all_sample_correlation(this_trait,
- target_dataset,
- corr_method="pearson") -> List:
+def speed_compute_all_sample_correlation(this_trait,
+ target_dataset,
+ corr_method="pearson") -> List:
"""Given a trait data sample-list and target__datasets compute all sample
correlation
+ this functions uses multiprocessing if not use the normal fun
"""
# xtodo fix trait_name currently returning single one
@@ -160,9 +161,9 @@ def compute_all_sample_correlation(this_trait,
key=lambda trait_name: -abs(list(trait_name.values())[0]["corr_coefficient"]))
-def benchmark_compute_all_sample(this_trait,
- target_dataset,
- corr_method="pearson") -> List:
+def compute_all_sample_correlation(this_trait,
+ target_dataset,
+ corr_method="pearson") -> List:
"""Temp function to benchmark with compute_all_sample_r alternative to
compute_all_sample_r where we use multiprocessing
@@ -174,6 +175,7 @@ def benchmark_compute_all_sample(this_trait,
target_trait_data = target_trait["trait_sample_data"]
this_vals, target_vals = filter_shared_sample_keys(
this_trait_samples, target_trait_data)
+
sample_correlation = compute_sample_r_correlation(
trait_name=trait_name,
corr_method=corr_method,
@@ -190,7 +192,9 @@ def benchmark_compute_all_sample(this_trait,
"num_overlap": num_overlap
}
corr_results.append({trait_name: corr_result})
- return corr_results
+ return sorted(
+ corr_results,
+ key=lambda trait_name: -abs(list(trait_name.values())[0]["corr_coefficient"]))
def tissue_correlation_for_trait(
@@ -336,7 +340,7 @@ def compute_all_lit_correlation(conn, trait_lists: List,
return sorted_lit_results
-def compute_all_tissue_correlation(primary_tissue_dict: dict,
+def compute_tissue_correlation(primary_tissue_dict: dict,
target_tissues_data: dict,
corr_method: str):
"""Function acts as an abstraction for tissue_correlation_for_trait\
@@ -382,9 +386,9 @@ def process_trait_symbol_dict(trait_symbol_dict, symbol_tissue_vals_dict) -> Lis
return traits_tissue_vals
-def compute_tissue_correlation(primary_tissue_dict: dict,
- target_tissues_data: dict,
- corr_method: str):
+def speed_compute_tissue_correlation(primary_tissue_dict: dict,
+ target_tissues_data: dict,
+ corr_method: str):
"""Experimental function that uses multiprocessing for computing tissue
correlation