From 515662ecabd5d3a90eef6987aa5f8d4dbe63611f Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Mon, 19 May 2014 22:03:31 +0000 Subject: Fixed sorting on the show trait page Added/improved the x and y axis on the bar graph and histogram GEMMA working but still really slow --- .../wqflask/marker_regression/marker_regression.py | 6 + wqflask/wqflask/show_trait/show_trait.py | 5 +- wqflask/wqflask/static/new/css/bar_chart.css | 4 +- .../wqflask/static/new/javascript/histogram.coffee | 38 +++++-- wqflask/wqflask/static/new/javascript/histogram.js | 16 ++- .../static/new/javascript/show_trait.coffee | 1 + .../new/javascript/show_trait_mapping_tools.coffee | 35 ++++++ .../new/javascript/show_trait_mapping_tools.js | 36 ++++++ wqflask/wqflask/templates/show_trait.html | 126 +++++++++++++++------ .../templates/show_trait_mapping_tools.html | 65 +++++++++-- 10 files changed, 270 insertions(+), 62 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 54cc9006..c220d2c9 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -58,6 +58,8 @@ class MarkerRegression(object): if self.mapping_method == "gemma": qtl_results = self.run_gemma() + elif self.mapping_method == "plink": + qtl_results = self.run_plink() elif self.mapping_method == "pylmm": #self.qtl_results = self.gen_data(tempdata) qtl_results = self.gen_data(str(temp_uuid)) @@ -151,6 +153,10 @@ class MarkerRegression(object): # # + def run_plink(self): + + os.chdir("/home/zas1024/plink") + #def gen_data(self, tempdata): def gen_data(self, temp_uuid): """Generates p-values for each marker""" diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index db8d4f1a..6f0ff44b 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -98,7 +98,10 @@ class ShowTrait(object): hddn['trait_id'] = self.trait_id hddn['dataset'] = self.dataset.name hddn['method'] = "pylmm" - + hddn['mapping_display_all'] = True + hddn['suggestive'] = 0 + hddn['maf'] = 0.01 + # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self self.hddn = hddn diff --git a/wqflask/wqflask/static/new/css/bar_chart.css b/wqflask/wqflask/static/new/css/bar_chart.css index c8e081f9..3e6e7bd6 100755 --- a/wqflask/wqflask/static/new/css/bar_chart.css +++ b/wqflask/wqflask/static/new/css/bar_chart.css @@ -9,7 +9,7 @@ fill: steelblue; shape-rendering: crispEdges; } - +/* .x.axis path { display: none; -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/histogram.coffee b/wqflask/wqflask/static/new/javascript/histogram.coffee index 6c1e65e9..98f89ac6 100755 --- a/wqflask/wqflask/static/new/javascript/histogram.coffee +++ b/wqflask/wqflask/static/new/javascript/histogram.coffee @@ -41,13 +41,15 @@ class Histogram create_x_scale: () -> console.log("min/max:", d3.min(@sample_vals) + "," + d3.max(@sample_vals)) - if (d3.min(@sample_vals) < 0) - min_domain = d3.min(@sample_vals) - else - min_domain = 0 + x0 = Math.max(-d3.min(@sample_vals), d3.max(@sample_vals)) + #if (d3.min(@sample_vals) < 0) + # min_domain = d3.min(@sample_vals) + #else + # min_domain = 0 @x_scale = d3.scale.linear() - .domain([min_domain, parseFloat(d3.max(@sample_vals))]) - .range([0, @plot_width]) + .domain([d3.min(@sample_vals), d3.max(@sample_vals)]) + .range([0, @plot_width]) + .nice() get_histogram_data: () -> console.log("sample_vals:", @sample_vals) @@ -62,6 +64,7 @@ class Histogram create_graph: () -> @add_x_axis() + @add_y_axis() @add_bars() add_x_axis: () -> @@ -74,11 +77,32 @@ class Histogram .attr("transform", "translate(0," + @plot_height + ")") .call(x_axis) + #add_y_axis: () -> + # y_axis = d3.svg.axis() + # .scale(@y_scale) + # .orient("left") + # .ticks(5) + # + # @svg.append("g") + # .attr("class", "y axis") + # #.attr("transform", "translate(0," + @plot_width + ")") + # .call(y_axis) + + add_y_axis: () -> - y_axis = d3.svg.axis() + yAxis = d3.svg.axis() .scale(@y_scale) .orient("left") .ticks(5) + + @svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") add_bars: () -> console.log("bar_width:", @x_scale(@histogram_data[0].dx)) diff --git a/wqflask/wqflask/static/new/javascript/histogram.js b/wqflask/wqflask/static/new/javascript/histogram.js index 1603cb77..d8067ced 100755 --- a/wqflask/wqflask/static/new/javascript/histogram.js +++ b/wqflask/wqflask/static/new/javascript/histogram.js @@ -55,14 +55,10 @@ }; Histogram.prototype.create_x_scale = function() { - var min_domain; + var x0; console.log("min/max:", d3.min(this.sample_vals) + "," + d3.max(this.sample_vals)); - if (d3.min(this.sample_vals) < 0) { - min_domain = d3.min(this.sample_vals); - } else { - min_domain = 0; - } - return this.x_scale = d3.scale.linear().domain([min_domain, parseFloat(d3.max(this.sample_vals))]).range([0, this.plot_width]); + x0 = Math.max(-d3.min(this.sample_vals), d3.max(this.sample_vals)); + return this.x_scale = d3.scale.linear().domain([d3.min(this.sample_vals), d3.max(this.sample_vals)]).range([0, this.plot_width]).nice(); }; Histogram.prototype.get_histogram_data = function() { @@ -82,6 +78,7 @@ Histogram.prototype.create_graph = function() { this.add_x_axis(); + this.add_y_axis(); return this.add_bars(); }; @@ -92,8 +89,9 @@ }; Histogram.prototype.add_y_axis = function() { - var y_axis; - return y_axis = d3.svg.axis().scale(this.y_scale).orient("left").ticks(5); + var yAxis; + yAxis = d3.svg.axis().scale(this.y_scale).orient("left").ticks(5); + return this.svg.append("g").attr("class", "y axis").call(yAxis).append("text").attr("transform", "rotate(-90)").attr("y", 6).attr("dy", ".71em").style("text-anchor", "end"); }; Histogram.prototype.add_bars = function() { diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee index 84e465e8..a410baf3 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee @@ -204,6 +204,7 @@ $ -> name = $.trim(name) real_value = $(row).find('.edit_sample_value').val() console.log("real_value:", real_value) + checkbox = $(row).find(".edit_sample_checkbox") checked = $(checkbox).attr('checked') diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee index f1024cd1..1d375686 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee @@ -56,6 +56,9 @@ $ -> console.log("In interval mapping") $("#progress_bar_container").modal() url = "/interval_mapping" + $('input[name=method]').val("reaper") + $('input[name=mapping_display_all]').val($('input[name=display_all_reaper]')) + $('input[name=suggestive]').val($('input[name=suggestive_reaper]')) form_data = $('#trait_data_form').serialize() console.log("form_data is:", form_data) $.ajax( @@ -116,9 +119,41 @@ $ -> return false ) + $("#plink_compute").click(() => + url = "/marker_regression" + $('input[name=method]').val("plink") + $('input[name=mapping_display_all]').val($('input[name=display_all_plink]')) + $('input[name=suggestive]').val($('input[name=suggestive_plink]')) + $('input[name=maf]').val($('input[name=maf_plink]')) + form_data = $('#trait_data_form').serialize() + console.log("form_data is:", form_data) + $.ajax( + type: "POST" + url: url + data: form_data + error: (xhr, ajaxOptions, thrownError) => + alert("Sorry, an error occurred") + console.log(xhr) + clearInterval(this.my_timer) + $('#progress_bar_container').modal('hide') + $("body").html("We got an error.") + success: (data) => + clearInterval(this.my_timer) + $('#progress_bar_container').modal('hide') + $("body").html(data) + ) + console.log("settingInterval") + + this.my_timer = setInterval(get_progress, 1000) + return false + ) + $("#gemma_compute").click(() => url = "/marker_regression" $('input[name=method]').val("gemma") + $('input[name=mapping_display_all]').val($('input[name=display_all_gemma]')) + $('input[name=suggestive]').val($('input[name=suggestive_gemma]')) + $('input[name=maf]').val($('input[name=maf_gemma]')) form_data = $('#trait_data_form').serialize() console.log("form_data is:", form_data) $.ajax( diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js index a5a49ace..dbc26e3b 100755 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -67,6 +67,9 @@ console.log("In interval mapping"); $("#progress_bar_container").modal(); url = "/interval_mapping"; + $('input[name=method]').val("reaper"); + $('input[name=mapping_display_all]').val($('input[name=display_all_reaper]')); + $('input[name=suggestive]').val($('input[name=suggestive_reaper]')); form_data = $('#trait_data_form').serialize(); console.log("form_data is:", form_data); $.ajax({ @@ -127,10 +130,43 @@ _this.my_timer = setInterval(get_progress, 1000); return false; }); + $("#plink_compute").click(function() { + var form_data, url; + url = "/marker_regression"; + $('input[name=method]').val("plink"); + $('input[name=mapping_display_all]').val($('input[name=display_all_plink]')); + $('input[name=suggestive]').val($('input[name=suggestive_plink]')); + $('input[name=maf]').val($('input[name=maf_plink]')); + form_data = $('#trait_data_form').serialize(); + console.log("form_data is:", form_data); + $.ajax({ + type: "POST", + url: url, + data: form_data, + error: function(xhr, ajaxOptions, thrownError) { + alert("Sorry, an error occurred"); + console.log(xhr); + clearInterval(_this.my_timer); + $('#progress_bar_container').modal('hide'); + return $("body").html("We got an error."); + }, + success: function(data) { + clearInterval(_this.my_timer); + $('#progress_bar_container').modal('hide'); + return $("body").html(data); + } + }); + console.log("settingInterval"); + _this.my_timer = setInterval(get_progress, 1000); + return false; + }); $("#gemma_compute").click(function() { var form_data, url; url = "/marker_regression"; $('input[name=method]').val("gemma"); + $('input[name=mapping_display_all]').val($('input[name=display_all_gemma]')); + $('input[name=suggestive]').val($('input[name=suggestive_gemma]')); + $('input[name=maf]').val($('input[name=maf_gemma]')); form_data = $('#trait_data_form').serialize(); console.log("form_data is:", form_data); $.ajax({ diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index e15d043b..ff05e859 100755 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -69,38 +69,98 @@ + - {% endblock %} diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index cc995f2f..f380988e 100755 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -9,6 +9,9 @@
  • Marker Regression
  • +
  • + PLINK +
  • GEMMA
  • @@ -114,20 +117,20 @@
    -
    - +
    @@ -151,32 +154,74 @@ + +
    -
    - +
    -
    - +
    -- cgit v1.2.3