aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.coffee108
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js101
-rw-r--r--wqflask/wqflask/static/new/javascript/stats.coffee14
-rw-r--r--wqflask/wqflask/static/new/javascript/stats.js17
-rw-r--r--wqflask/wqflask/templates/show_trait_details.html2
-rw-r--r--wqflask/wqflask/views.py12
6 files changed, 175 insertions, 79 deletions
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee
index 3d9fcd5a..278a134b 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee
@@ -4,6 +4,61 @@ console.log("start_b")
is_number = (o) ->
return ! isNaN (o-0) && o != null
+Stat_Table_Rows = [
+ {
+ vn: "n_of_samples"
+ pretty: "N of Samples"
+ digits: 0
+ },
+ {
+ vn: "mean"
+ pretty: "Mean"
+ digits: 2
+ },
+ {
+ vn: "median"
+ pretty: "Median"
+ digits: 2
+ },
+ {
+ vn: "std_error"
+ pretty: "Standard Error (SE)"
+ digits: 2
+ },
+ {
+ vn: "std_dev"
+ pretty: "Standard Deviation (SD)"
+ digits: 2
+ },
+ {
+ vn: "min"
+ pretty: "Minimum"
+ digits: 2
+ },
+ {
+ vn: "max"
+ pretty: "Maximum"
+ digits: 2
+ },
+ {
+ vn: "range"
+ pretty: "Range (log2)"
+ digits: 2
+ },
+ {
+ vn: "range_fold"
+ pretty: "Range (fold)"
+ digits: 2
+ },
+ {
+ vn: "interquartile"
+ pretty: "Interquartile Range"
+ url: "/glossary.html#Interquartile"
+ digits: 2
+ }
+
+ ]
+
$ ->
hide_tabs = (start) ->
for x in [start..10]
@@ -30,19 +85,29 @@ $ ->
the_value = sample_sets[category][value_type]()
console.log("After running sample_sets, the_value is:", the_value)
if decimal_places > 0
+ title_value = the_value.toFixed(decimal_places * 2)
the_value = the_value.toFixed(decimal_places)
+ else
+ title_value = null
console.log("*-* the_value:", the_value)
console.log("*-* current_value:", current_value)
if the_value != current_value
$(id).html(the_value).effect("highlight")
+ # We go ahead and always change the title value if we have it
+ if title_value
+ $(id).attr('title', title_value)
+
update_stat_values = (sample_sets)->
for category in ['samples_primary', 'samples_other', 'samples_all']
- change_stats_value(sample_sets, category, "n_of_samples", 0)
- for stat in ["mean", "median", "std_dev", "std_error", "min", "max"]
+ #change_stats_value(sample_sets, category, "n_of_samples", 0)
+
+ #for stat in ["mean", "median", "std_dev", "std_error", "min", "max"]
+ #for stat in (row.vn for row in Stat_Table_Rows)
+ for row in Stat_Table_Rows
console.log("Calling change_stats_value")
- change_stats_value(sample_sets, category, stat, 2)
+ change_stats_value(sample_sets, category, row.vn, row.digits)
edit_data_change = ->
sample_sets =
@@ -94,41 +159,10 @@ $ ->
header += "</thead>"
console.log("windex header is:", header)
- rows = [
- {
- vn: "n_of_samples"
- pretty: "N of Samples"
- },
- {
- vn: "mean"
- pretty: "Mean"
- },
- {
- vn: "median"
- pretty: "Median"
- },
- {
- vn: "std_error"
- pretty: "Standard Error (SE)"
- },
- {
- vn: "std_dev"
- pretty: "Standard Deviation (SD)"
- },
- {
- vn: "min"
- pretty: "Minimum"
- },
- {
- vn: "max"
- pretty: "Maximum"
- }
- ]
-
- console.log("rows are:", rows)
+ #console.log("rows are:", rows)
the_rows = "<tbody>"
- console.log("length of rows:", rows.length)
- for row in rows
+ #console.log("length of rows:", rows.length)
+ for row in Stat_Table_Rows
console.log("rowing")
row_line = """<tr>"""
row_line += """<td id="#{ row.vn }">#{ row.pretty }</td>"""
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 84282aef..3a7bc387 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.3.3
(function() {
- var is_number,
+ var Stat_Table_Rows, is_number,
__hasProp = {}.hasOwnProperty,
__slice = [].slice;
@@ -10,6 +10,51 @@
return !isNaN((o - 0) && o !== null);
};
+ Stat_Table_Rows = [
+ {
+ vn: "n_of_samples",
+ pretty: "N of Samples",
+ digits: 0
+ }, {
+ vn: "mean",
+ pretty: "Mean",
+ digits: 2
+ }, {
+ vn: "median",
+ pretty: "Median",
+ digits: 2
+ }, {
+ vn: "std_error",
+ pretty: "Standard Error (SE)",
+ digits: 2
+ }, {
+ vn: "std_dev",
+ pretty: "Standard Deviation (SD)",
+ digits: 2
+ }, {
+ vn: "min",
+ pretty: "Minimum",
+ digits: 2
+ }, {
+ vn: "max",
+ pretty: "Maximum",
+ digits: 2
+ }, {
+ vn: "range",
+ pretty: "Range (log2)",
+ digits: 2
+ }, {
+ vn: "range_fold",
+ pretty: "Range (fold)",
+ digits: 2
+ }, {
+ vn: "interquartile",
+ pretty: "Interquartile Range",
+ url: "/glossary.html#Interquartile",
+ digits: 2
+ }
+ ];
+
$(function() {
var block_by_attribute_value, block_by_index, block_outliers, change_stats_value, create_value_dropdown, edit_data_change, export_sample_table_data, get_sample_table_data, hide_no_value, hide_tabs, make_table, on_corr_method_change, populate_sample_attributes_values_dropdown, process_id, reset_samples_table, show_hide_outliers, stats_mdp_change, update_stat_values;
hide_tabs = function(start) {
@@ -27,7 +72,7 @@
return $("#stats_tabs" + selected).show();
};
change_stats_value = function(sample_sets, category, value_type, decimal_places) {
- var current_value, id, in_box, the_value;
+ var current_value, id, in_box, the_value, title_value;
id = "#" + process_id(category, value_type);
console.log("the_id:", id);
in_box = $(id).html;
@@ -36,29 +81,33 @@
the_value = sample_sets[category][value_type]();
console.log("After running sample_sets, the_value is:", the_value);
if (decimal_places > 0) {
+ title_value = the_value.toFixed(decimal_places * 2);
the_value = the_value.toFixed(decimal_places);
+ } else {
+ title_value = null;
}
console.log("*-* the_value:", the_value);
console.log("*-* current_value:", current_value);
if (the_value !== current_value) {
- return $(id).html(the_value).effect("highlight");
+ $(id).html(the_value).effect("highlight");
+ }
+ if (title_value) {
+ return $(id).attr('title', title_value);
}
};
update_stat_values = function(sample_sets) {
- var category, stat, _i, _len, _ref, _results;
+ var category, row, _i, _len, _ref, _results;
_ref = ['samples_primary', 'samples_other', 'samples_all'];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
category = _ref[_i];
- change_stats_value(sample_sets, category, "n_of_samples", 0);
_results.push((function() {
- var _j, _len1, _ref1, _results1;
- _ref1 = ["mean", "median", "std_dev", "std_error", "min", "max"];
+ var _j, _len1, _results1;
_results1 = [];
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- stat = _ref1[_j];
+ for (_j = 0, _len1 = Stat_Table_Rows.length; _j < _len1; _j++) {
+ row = Stat_Table_Rows[_j];
console.log("Calling change_stats_value");
- _results1.push(change_stats_value(sample_sets, category, stat, 2));
+ _results1.push(change_stats_value(sample_sets, category, row.vn, row.digits));
}
return _results1;
})());
@@ -96,7 +145,7 @@
return update_stat_values(sample_sets);
};
make_table = function() {
- var header, key, row, row_line, rows, table, the_id, the_rows, value, _i, _len, _ref, _ref1;
+ var header, key, row, row_line, table, the_id, the_rows, value, _i, _len, _ref, _ref1;
header = "<thead><tr><th>&nbsp;</th>";
console.log("js_data.sample_group_types:", js_data.sample_group_types);
_ref = js_data.sample_group_types;
@@ -110,35 +159,9 @@
}
header += "</thead>";
console.log("windex header is:", header);
- rows = [
- {
- vn: "n_of_samples",
- pretty: "N of Samples"
- }, {
- vn: "mean",
- pretty: "Mean"
- }, {
- vn: "median",
- pretty: "Median"
- }, {
- vn: "std_error",
- pretty: "Standard Error (SE)"
- }, {
- vn: "std_dev",
- pretty: "Standard Deviation (SD)"
- }, {
- vn: "min",
- pretty: "Minimum"
- }, {
- vn: "max",
- pretty: "Maximum"
- }
- ];
- console.log("rows are:", rows);
the_rows = "<tbody>";
- console.log("length of rows:", rows.length);
- for (_i = 0, _len = rows.length; _i < _len; _i++) {
- row = rows[_i];
+ for (_i = 0, _len = Stat_Table_Rows.length; _i < _len; _i++) {
+ row = Stat_Table_Rows[_i];
console.log("rowing");
row_line = "<tr>";
row_line += "<td id=\"" + row.vn + "\">" + row.pretty + "</td>";
diff --git a/wqflask/wqflask/static/new/javascript/stats.coffee b/wqflask/wqflask/static/new/javascript/stats.coffee
index 118ee7a8..d6d39245 100644
--- a/wqflask/wqflask/static/new/javascript/stats.coffee
+++ b/wqflask/wqflask/static/new/javascript/stats.coffee
@@ -42,6 +42,20 @@ class Stats
max: ->
return Math.max(@the_values...)
+ range: ->
+ return @max() - @min()
+
+ range_fold: ->
+ return Math.pow(2, @range())
+
+ interquartile: ->
+ length = @the_values.length
+ # Todo: Consider averaging q1 and a3 when the length is odd
+ q1 = @the_values[Math.round(length * .25)]
+ q3 = @the_values[Math.round(length * .75)]
+ iq = q3 - q1
+ return Math.pow(2, iq)
+
bxd_only = new Stats([3, 5, 7, 8])
console.log("[xred] bxd_only mean:", bxd_only.mean())
diff --git a/wqflask/wqflask/static/new/javascript/stats.js b/wqflask/wqflask/static/new/javascript/stats.js
index 620f7d5d..5b7603ba 100644
--- a/wqflask/wqflask/static/new/javascript/stats.js
+++ b/wqflask/wqflask/static/new/javascript/stats.js
@@ -70,6 +70,23 @@
return Math.max.apply(Math, this.the_values);
};
+ Stats.prototype.range = function() {
+ return this.max() - this.min();
+ };
+
+ Stats.prototype.range_fold = function() {
+ return Math.pow(2, this.range());
+ };
+
+ Stats.prototype.interquartile = function() {
+ var iq, length, q1, q3;
+ length = this.the_values.length;
+ q1 = this.the_values[Math.round(length * .25)];
+ q3 = this.the_values[Math.round(length * .75)];
+ iq = q3 - q1;
+ return Math.pow(2, iq);
+ };
+
return Stats;
})();
diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html
index e04fdd66..4b3862c7 100644
--- a/wqflask/wqflask/templates/show_trait_details.html
+++ b/wqflask/wqflask/templates/show_trait_details.html
@@ -7,7 +7,7 @@
<dt>Database</dt>
<dd>
- <a href="{{ this_trait.database.url }}" target="_blank">
+ <a href="{{ url_for('static', filename='/dbdoc/' + dataset.fullname + '.html') }}" target="_blank">
{{ dataset.name }}
</a>
</dd>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 17dc42fb..70d8cd20 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -4,6 +4,7 @@ import csv
import StringIO # Todo: Use cStringIO?
import simplejson as json
+#import json
import yaml
import flask
@@ -95,10 +96,17 @@ def show_trait_page():
#fd = webqtlFormData.webqtlFormData(request.args)
#print("stp y1:", pf(vars(fd)))
template_vars = show_trait.ShowTrait(request.args)
+
+ print("js_data before dump:", template_vars.js_data)
+
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
- indent=" ",
- sort_keys=True)
+ indent=" ")
+ # Sorting the keys messes up the ordered dictionary, so don't do that
+ #sort_keys=True)
+
+ print("js_data after dump:", template_vars.js_data)
+
print("show_trait template_vars:", pf(template_vars.__dict__))
return render_template("show_trait.html", **template_vars.__dict__)