aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/corr_result_helpers.py
diff options
context:
space:
mode:
authorzsloan2016-06-20 11:03:20 -0500
committerGitHub2016-06-20 11:03:20 -0500
commit8222ef16d443dc41db9d7e09b1af400d8d866854 (patch)
treee4f5b49aa21c32aa2b770b1a65c8fef7782b625f /wqflask/utility/corr_result_helpers.py
parentd90dc3748557d1d6fbaa59f71fe676b8a7c393ca (diff)
parent10df36b60273d81678f6630c07a2d8e5a6409282 (diff)
downloadgenenetwork2-8222ef16d443dc41db9d7e09b1af400d8d866854.tar.gz
Merge pull request #168 from genenetwork/staging
Staging
Diffstat (limited to 'wqflask/utility/corr_result_helpers.py')
-rwxr-xr-xwqflask/utility/corr_result_helpers.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/wqflask/utility/corr_result_helpers.py b/wqflask/utility/corr_result_helpers.py
index a253026c..ef644d85 100755
--- a/wqflask/utility/corr_result_helpers.py
+++ b/wqflask/utility/corr_result_helpers.py
@@ -1,16 +1,16 @@
def normalize_values(a_values, b_values):
"""
Trim two lists of values to contain only the values they both share
-
+
Given two lists of sample values, trim each list so that it contains
only the samples that contain a value in both lists. Also returns
the number of such samples.
-
+
>>> normalize_values([2.3, None, None, 3.2, 4.1, 5], [3.4, 7.2, 1.3, None, 6.2, 4.1])
([2.3, 4.1, 5], [3.4, 6.2, 4.1], 3)
-
+
"""
-
+
min_length = min(len(a_values), len(b_values))
a_new = []
b_new = []
@@ -18,10 +18,10 @@ def normalize_values(a_values, b_values):
if a_values[counter] and b_values[counter]:
a_new.append(a_values[counter])
b_new.append(b_values[counter])
-
+
num_overlap = len(a_new)
assert num_overlap == len(b_new), "Lengths should be the same"
-
+
return a_new, b_new, num_overlap
@@ -37,16 +37,16 @@ def common_keys(a_samples, b_samples):
def normalize_values_with_samples(a_samples, b_samples):
common_samples = common_keys(a_samples, b_samples)
-
+
a_new = {}
b_new = {}
for sample in common_samples:
a_new[sample] = a_samples[sample]
b_new[sample] = b_samples[sample]
-
+
num_overlap = len(a_new)
assert num_overlap == len(b_new), "Lengths should be the same"
-
+
return a_new, b_new, num_overlap