From d10410bfd90283bbab8a7496533da3b650e08748 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 9 Jan 2013 16:21:12 -0600 Subject: Got the permutation plot working as a line plot; still need to make it into a bar graph, though --- .../wqflask/marker_regression/marker_regression.py | 5 +- .../static/new/javascript/marker_regression.coffee | 44 ++++++++++++++++ .../static/new/javascript/marker_regression.js | 58 ++++++++++++++++++++++ wqflask/wqflask/templates/base.html | 5 +- wqflask/wqflask/templates/marker_regression.html | 12 +++++ 5 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 wqflask/wqflask/static/new/javascript/marker_regression.coffee create mode 100644 wqflask/wqflask/static/new/javascript/marker_regression.js diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 615f6f77..52870d84 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -304,12 +304,9 @@ class MarkerRegression(object): # end: common part with human data self.js_data = dict( - #qtl_results = self.pure_qtl_results, + qtl_results = self.pure_qtl_results, lrs_array = self.lrs_array, ) - - print("bears self.js_data is: ", pf(self.js_data)) - # add by NL 10-2-2011 diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee new file mode 100644 index 00000000..ec428cfa --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee @@ -0,0 +1,44 @@ +$ -> + sort_number = (a, b) -> + return a - b + + process_lrs_array = -> + lrs_array = js_data.lrs_array + bars = {} + for lrs in lrs_array + floored = Math.floor(lrs) + if floored not of bars + bars[floored] = 0 + bars[floored] += 1 + + keys = [] + for key of bars + keys.push(key) + keys.sort(sort_number) + + bars_ordered = [] + for key in keys + bars_ordered.push([parseInt(key), bars[key]]) + + console.log("bars is:", bars) + console.log("keys are:", keys) + console.log("bars_ordered are:", bars_ordered) + return bars_ordered + + display_permutation_histogram = (bars_ordered) -> + $.jqplot('permutation_histogram', [bars_ordered], + seriesDefaults: + renderer:$.jqplot.BarRenderer + axes: + xaxis: + min: 0 + label: "LRS", + pad: 0 + yaxis: + label: "Count", + pad: 0 + ) + + + bars_ordered = process_lrs_array() + display_permutation_histogram(bars_ordered) \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js new file mode 100644 index 00000000..0b186242 --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/marker_regression.js @@ -0,0 +1,58 @@ +// Generated by CoffeeScript 1.3.3 +(function() { + + $(function() { + var bars_ordered, display_permutation_histogram, process_lrs_array, sort_number; + sort_number = function(a, b) { + return a - b; + }; + process_lrs_array = function() { + var bars, bars_ordered, floored, key, keys, lrs, lrs_array, _i, _j, _len, _len1; + lrs_array = js_data.lrs_array; + bars = {}; + for (_i = 0, _len = lrs_array.length; _i < _len; _i++) { + lrs = lrs_array[_i]; + floored = Math.floor(lrs); + if (!(floored in bars)) { + bars[floored] = 0; + } + bars[floored] += 1; + } + keys = []; + for (key in bars) { + keys.push(key); + } + keys.sort(sort_number); + bars_ordered = []; + for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { + key = keys[_j]; + bars_ordered.push([parseInt(key), bars[key]]); + } + console.log("bars is:", bars); + console.log("keys are:", keys); + console.log("bars_ordered are:", bars_ordered); + return bars_ordered; + }; + display_permutation_histogram = function(bars_ordered) { + return $.jqplot('permutation_histogram', [bars_ordered], { + seriesDefaults: { + renderer: $.jqplot.BarRenderer + }, + axes: { + xaxis: { + min: 0, + label: "LRS", + pad: 0 + }, + yaxis: { + label: "Count", + pad: 0 + } + } + }); + }; + bars_ordered = process_lrs_array(); + return display_permutation_histogram(bars_ordered); + }); + +}).call(this); diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 21b93004..2a60d184 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -4,7 +4,7 @@ - GeneNetwork + {% block title %}{% endblock %} GeneNetwork @@ -16,6 +16,9 @@ + + {% block css %} + {% endblock %} diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html index 2fe20fb0..6464bc77 100644 --- a/wqflask/wqflask/templates/marker_regression.html +++ b/wqflask/wqflask/templates/marker_regression.html @@ -1,5 +1,8 @@ {% extends "base.html" %} {% block title %}Marker Regression{% endblock %} +{% block css %} + +{% endblock %} {% block content %}
@@ -10,6 +13,8 @@

+ +
@@ -20,4 +25,11 @@ + + + + + {% endblock %} \ No newline at end of file -- cgit v1.2.3