aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabui2021-08-20 09:04:12 +0300
committerGitHub2021-08-20 09:04:12 +0300
commitc9ee473ff7797f6bbd7507eb55c772a3a646acee (patch)
treed14302938081ce61637ae84cda2077aaf0db9733
parentf8be3a85567cc17d50a01382eb10cb3b05436214 (diff)
downloadgenenetwork3-c9ee473ff7797f6bbd7507eb55c772a3a646acee.tar.gz
Minor correlation fixes (#36)
* fix key error for (*tissue_cor) tissue correlation * update tests for tissue correlation * rename speed_compute to fast_compute * pep8 formatting
-rw-r--r--gn3/computations/correlations.py15
-rw-r--r--tests/unit/computations/test_correlation.py8
2 files changed, 11 insertions, 12 deletions
diff --git a/gn3/computations/correlations.py b/gn3/computations/correlations.py
index 8d76c09..bb13ff1 100644
--- a/gn3/computations/correlations.py
+++ b/gn3/computations/correlations.py
@@ -124,9 +124,9 @@ def filter_shared_sample_keys(this_samplelist,
return (this_vals, target_vals)
-def speed_compute_all_sample_correlation(this_trait,
- target_dataset,
- corr_method="pearson") -> List:
+def fast_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
@@ -362,8 +362,7 @@ def compute_tissue_correlation(primary_tissue_dict: dict,
target_tissues_values=target_tissue_vals,
trait_id=trait_id,
corr_method=corr_method)
- tissue_result_dict = {trait_id: tissue_result}
- tissues_results.append(tissue_result_dict)
+ tissues_results.append(tissue_result)
return sorted(
tissues_results,
key=lambda trait_name: -abs(list(trait_name.values())[0]["tissue_corr"]))
@@ -386,9 +385,9 @@ def process_trait_symbol_dict(trait_symbol_dict, symbol_tissue_vals_dict) -> Lis
return traits_tissue_vals
-def speed_compute_tissue_correlation(primary_tissue_dict: dict,
- target_tissues_data: dict,
- corr_method: str):
+def fast_compute_tissue_correlation(primary_tissue_dict: dict,
+ target_tissues_data: dict,
+ corr_method: str):
"""Experimental function that uses multiprocessing for computing tissue
correlation
diff --git a/tests/unit/computations/test_correlation.py b/tests/unit/computations/test_correlation.py
index f2d65bd..fc52ec1 100644
--- a/tests/unit/computations/test_correlation.py
+++ b/tests/unit/computations/test_correlation.py
@@ -406,10 +406,10 @@ class TestCorrelation(TestCase):
target_tissue_data = {"trait_symbol_dict": target_trait_symbol,
"symbol_tissue_vals_dict": target_symbol_tissue_vals}
- mock_tissue_corr.side_effect = [{"tissue_corr": -0.5, "tissue_p_val": 0.9,
- "tissue_number": 3},
- {"tissue_corr": 1.11, "tissue_p_val": 0.2,
- "tissue_number": 3}]
+ mock_tissue_corr.side_effect = [{"1418702_a_at": {"tissue_corr": -0.5, "tissue_p_val": 0.9,
+ "tissue_number": 3}},
+ {"1412_at": {"tissue_corr": 1.11, "tissue_p_val": 0.2,
+ "tissue_number": 3}}]
expected_results = [{"1412_at":
{"tissue_corr": 1.11, "tissue_p_val": 0.2, "tissue_number": 3}},