From 2085f376bc1a6fbb1a2d66f2220552e7c2baffdb Mon Sep 17 00:00:00 2001 From: Lei Yan Date: Thu, 17 Oct 2013 16:51:45 -0500 Subject: Added file for the correlation scatterplot and added the @app to views.py Added the link to the corr plot page to the correlation page template --- wqflask/wqflask/correlation/corr_scatter_plot.py | 28 ++++++++++++++++++++++++ wqflask/wqflask/templates/correlation_page.html | 2 +- wqflask/wqflask/views.py | 6 ++++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 wqflask/wqflask/correlation/corr_scatter_plot.py (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py new file mode 100644 index 00000000..c3ae110d --- /dev/null +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -0,0 +1,28 @@ +from __future__ import absolute_import, print_function, division + +from base.trait import GeneralTrait +from base import data_set +from utility import corr_result_helpers + +class CorrScatterPlot(object): + + def __init__(self, params): + print("params are:", params) + self.data_set_1 = data_set.create_dataset(params['dataset_1']) + self.data_set_2 = data_set.create_dataset(params['dataset_2']) + self.trait_1 = GeneralTrait(name=params['trait_1'], dataset=self.data_set_1) + self.trait_2 = GeneralTrait(name=params['trait_2'], dataset=self.data_set_2) + + vals_1 = [] + for sample in self.trait_1.data.keys(): + vals_1.append(self.trait_1.data[sample].value) + vals_2 = [] + 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) + + self.js_data = dict( + vals_1 = vals_1, + vals_2 = vals_2 + ) \ No newline at end of file diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 4d09cf20..7db8ea49 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -52,7 +52,7 @@ {{'%0.3f'|format(trait.mean)}} {{'%0.3f'|format(trait.lrs)}} Chr{{ trait.locus_chr }}:{{'%0.6f'|format(trait.locus_mb)}} - {{'%0.3f'|format(trait.sample_r)}} + {{'%0.3f'|format(trait.sample_r)}} {{ trait.num_overlap }} {{'%0.3e'|format(trait.sample_p)}} {{'%0.3f'|format(trait.lit_corr)}} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index deccf459..98b6039f 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -246,7 +246,6 @@ def marker_regression_page(): return rendered_template - @app.route("/corr_compute", methods=('POST',)) def corr_compute_page(): print("In corr_compute, request.form is:", pf(request.form)) @@ -254,6 +253,11 @@ def corr_compute_page(): template_vars = show_corr_results.CorrelationResults(request.form) return render_template("correlation_page.html", **template_vars.__dict__) +@app.route("/corr_scatter_plot") +def corr_scatter_plot_page(): + template_vars = corr_scatter_plot.CorrScatterPlot(request.args) + return render_template("corr_scatter_plot.html", **template_vars.__dict__) + @app.route("/int_mapping", methods=('POST',)) def interval_mapping_page(): template_vars = interval_mapping.IntervalMapping(request.args) -- cgit v1.2.3