diff options
author | Lei Yan | 2013-10-17 17:56:39 -0500 |
---|---|---|
committer | Lei Yan | 2013-10-17 17:56:39 -0500 |
commit | a3d83256b1e4e25b1542e32d61d912c57ab9a70a (patch) | |
tree | f223c62437f85733c4da109d87ddd8ccf54a940d | |
parent | 2a1f08bcecf6273390997d122d552a01e0311e40 (diff) | |
download | genenetwork2-a3d83256b1e4e25b1542e32d61d912c57ab9a70a.tar.gz |
Sample objects are now passed to js_data for drawing the correlation
scatter plot
-rw-r--r-- | wqflask/utility/corr_result_helpers.py | 26 | ||||
-rw-r--r-- | wqflask/wqflask/correlation/corr_scatter_plot.py | 11 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 3 |
3 files changed, 35 insertions, 5 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 diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py index c3ae110d..dd4e439a 100644 --- a/wqflask/wqflask/correlation/corr_scatter_plot.py +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -20,9 +20,12 @@ class CorrScatterPlot(object): for sample in self.trait_2.data.keys(): vals_2.append(self.trait_2.data[sample].value) - vals_1, vals_2, num_overlap = corr_result_helpers.normalize_values(vals_1, vals_2) + samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples( + self.trait_1.data, self.trait_2.data) self.js_data = dict( - vals_1 = vals_1, - vals_2 = vals_2 - )
\ No newline at end of file + samples_1 = samples_1, + samples_2 = samples_2 + ) + + print("Self.js_data:", self.js_data)
\ No newline at end of file diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index e6b99649..4cf540f6 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -32,8 +32,9 @@ from base.data_set import create_datasets_list from wqflask.show_trait import show_trait from wqflask.show_trait import export_trait_data from wqflask.marker_regression import marker_regression -from wqflask.interval_mapping import interval_mapping +#from wqflask.interval_mapping import interval_mapping from wqflask.correlation import show_corr_results +from wqflask.correlation import corr_scatter_plot from utility import temp_data from wqflask.dataSharing import SharingInfo, SharingInfoPage |