aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorLei Yan2013-10-17 17:56:39 -0500
committerLei Yan2013-10-17 17:56:39 -0500
commita3d83256b1e4e25b1542e32d61d912c57ab9a70a (patch)
treef223c62437f85733c4da109d87ddd8ccf54a940d /wqflask/utility
parent2a1f08bcecf6273390997d122d552a01e0311e40 (diff)
downloadgenenetwork2-a3d83256b1e4e25b1542e32d61d912c57ab9a70a.tar.gz
Sample objects are now passed to js_data for drawing the correlation
scatter plot
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/corr_result_helpers.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/wqflask/utility/corr_result_helpers.py b/wqflask/utility/corr_result_helpers.py
index edf32449..a253026c 100644
--- a/wqflask/utility/corr_result_helpers.py
+++ b/wqflask/utility/corr_result_helpers.py
@@ -25,6 +25,32 @@ def normalize_values(a_values, b_values):
return a_new, b_new, num_overlap
+def common_keys(a_samples, b_samples):
+ """
+ >>> a = dict(BXD1 = 9.113, BXD2 = 9.825, BXD14 = 8.985, BXD15 = 9.300)
+ >>> b = dict(BXD1 = 9.723, BXD3 = 9.825, BXD14 = 9.124, BXD16 = 9.300)
+ >>> sorted(common_keys(a, b))
+ ['BXD1', 'BXD14']
+ """
+ return set(a_samples.keys()).intersection(set(b_samples.keys()))
+
+
+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
+
+
+
if __name__ == '__main__':
import doctest
doctest.testmod() \ No newline at end of file