about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZachary Sloan2013-01-09 16:21:12 -0600
committerZachary Sloan2013-01-09 16:21:12 -0600
commitd10410bfd90283bbab8a7496533da3b650e08748 (patch)
treec3568e515c67964798f90916d869e4720267ebb9
parent1685d588ecfb13a1a5c0f5aa10018e7ddbab7244 (diff)
downloadgenenetwork2-d10410bfd90283bbab8a7496533da3b650e08748.tar.gz
Got the permutation plot working as a line plot; still need to make
it into a bar graph, though
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py5
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.coffee44
-rw-r--r--wqflask/wqflask/static/new/javascript/marker_regression.js58
-rw-r--r--wqflask/wqflask/templates/base.html5
-rw-r--r--wqflask/wqflask/templates/marker_regression.html12
5 files changed, 119 insertions, 5 deletions
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 @@
 
 <head>
     <meta charset="utf-8">
-    <title>GeneNetwork</title>
+    <title>{% block title %}{% endblock %} GeneNetwork</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="description" content="">
     <meta name="author" content="">
@@ -16,6 +16,9 @@
     <!--[if lt IE 9]>
       <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->
+    
+    {% block css %}
+    {% endblock %}
 
 </head>
 
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 %}
+    <link rel="stylesheet" type="text/css" href="/static/packages/jqplot/jquery.jqplot.min.css" />
+{% endblock %}
 {% block content %} <!-- Start of body -->
 
     <header class="jumbotron subhead" id="overview">
@@ -10,6 +13,8 @@
             </p>
         </div>
     </header>
+    
+    <div id="permutation_histogram" style="height:300px;width:600px; "></div>
 
 
     <!-- End of body -->
@@ -20,4 +25,11 @@
     <script>
         js_data = {{ js_data | safe }}
     </script>
+
+    <!--[if lt IE 9]>
+        <script language="javascript" type="text/javascript" src="/static/packages/jqplot/excanvas.js"></script>
+    <![endif]-->
+    <script language="javascript" type="text/javascript" src="/static/packages/jqplot/plugins/jqplot.barRenderer.min.js"></script>
+    <script language="javascript" type="text/javascript" src="/static/packages/jqplot/jquery.jqplot.min.js"></script>
+    <script language="javascript" type="text/javascript" src="/static/new/javascript/marker_regression.js"></script>
 {% endblock %}
\ No newline at end of file