aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations/correlations.py
diff options
context:
space:
mode:
authorAlexander Kabui2021-11-29 00:33:26 +0300
committerBonfaceKilz2021-12-10 09:58:29 +0300
commitf32eb3269733345da8e0e7149a47ba33be11d611 (patch)
treec75fbd3de7e2def258f54f190ae9607334357224 /gn3/computations/correlations.py
parent9fa90438672f7a96740a489f2b2fc3f2b32a99b0 (diff)
downloadgenenetwork3-f32eb3269733345da8e0e7149a47ba33be11d611.tar.gz
try and catch for non matching sample keys
Diffstat (limited to 'gn3/computations/correlations.py')
-rw-r--r--gn3/computations/correlations.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/gn3/computations/correlations.py b/gn3/computations/correlations.py
index 1f90b6c..7c53563 100644
--- a/gn3/computations/correlations.py
+++ b/gn3/computations/correlations.py
@@ -38,13 +38,13 @@ def map_shared_keys_to_values(target_sample_keys: List,
return target_dataset_data
-def normalize_values(a_values: List,b_values: List):
+def normalize_values(a_values: List, b_values: List):
"""
input:nested two list of primary and target values *includes None vals
output: yield two list of normalized values elimate if none
"""
-
+
for a_val, b_val in zip(a_values, b_values):
if (a_val and b_val is not None):
yield a_val, b_val
@@ -166,8 +166,14 @@ def compute_all_sample_correlation(this_trait,
for target_trait in target_dataset:
trait_name = target_trait.get("trait_id")
target_trait_data = target_trait["trait_sample_data"]
- this_vals, target_vals = list(zip(*list(filter_shared_sample_keys(
- this_trait_samples, target_trait_data))))
+
+ try:
+ this_vals, target_vals = list(zip(*list(filter_shared_sample_keys(
+ this_trait_samples, target_trait_data))))
+
+ except ValueError:
+ # case where no matching strain names
+ this_vals, target_vals = []
sample_correlation = compute_sample_r_correlation(
trait_name=trait_name,