Created
July 17, 2015 18:12
-
-
Save lomereiter/cd82e9d31cbde415d08d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py | |
index a572a60..b152357 100755 | |
--- a/wqflask/base/data_set.py | |
+++ b/wqflask/base/data_set.py | |
@@ -555,12 +555,22 @@ class DataSet(object): | |
# """ % (query_args)) | |
try: | |
- self.id, self.name, self.fullname, self.shortname = g.db.execute(""" | |
+ if self.type != "ProbeSet": | |
+ self.datascale = None | |
+ self.id, self.name, self.fullname, self.shortname = g.db.execute(""" | |
SELECT Id, Name, FullName, ShortName | |
FROM %s | |
WHERE public > %s AND | |
(Name = '%s' OR FullName = '%s' OR ShortName = '%s') | |
- """ % (query_args)).fetchone() | |
+ """ % (query_args)).fetchone() | |
+ else: | |
+ self.id, self.name, self.fullname, self.shortname, self.datascale = g.db.execute(""" | |
+ SELECT Id, Name, FullName, ShortName, DataScale | |
+ FROM %s | |
+ WHERE public > %s AND | |
+ (Name = '%s' OR FullName = '%s' OR ShortName = '%s') | |
+ """ % (query_args)).fetchone() | |
+ | |
except TypeError: | |
print("Dataset {} is not yet available in GeneNetwork.".format(self.name)) | |
pass | |
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py | |
index 0247226..05f99a9 100755 | |
--- a/wqflask/wqflask/show_trait/show_trait.py | |
+++ b/wqflask/wqflask/show_trait/show_trait.py | |
@@ -146,7 +146,9 @@ class ShowTrait(object): | |
js_data = dict(sample_group_types = self.sample_group_types, | |
sample_lists = sample_lists, | |
attribute_names = self.sample_groups[0].attributes, | |
- temp_uuid = self.temp_uuid) | |
+ temp_uuid = self.temp_uuid, | |
+ dataset_type = self.dataset.type, | |
+ datascale = self.dataset.datascale) | |
self.js_data = js_data | |
def get_mapping_methods(self): | |
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.coffee b/wqflask/wqflask/static/new/javascript/show_trait.coffee | |
index 91aa15b..592158c 100755 | |
--- a/wqflask/wqflask/static/new/javascript/show_trait.coffee | |
+++ b/wqflask/wqflask/static/new/javascript/show_trait.coffee | |
@@ -6,7 +6,7 @@ console.log("start_b") | |
is_number = (o) -> | |
return ! isNaN (o-0) && o != null | |
-Stat_Table_Rows = [ | |
+Common_Stat_Table_Rows = [ | |
{ | |
vn: "n_of_samples" | |
pretty: "N of Samples" | |
@@ -41,10 +41,13 @@ Stat_Table_Rows = [ | |
vn: "max" | |
pretty: "Maximum" | |
digits: 2 | |
- }, | |
+ } | |
+ ] | |
+ | |
+Extra_Stat_Table_Rows = [ | |
{ | |
vn: "range" | |
- pretty: "Range (log2)" | |
+ pretty: "Range" + (if js_data.datascale == "linear" then "" else " (log2)") | |
digits: 2 | |
}, | |
{ | |
@@ -62,6 +65,12 @@ Stat_Table_Rows = [ | |
$ -> | |
+ stat_table_rows = -> | |
+ rows = Common_Stat_Table_Rows | |
+ if js_data.dataset_type == "ProbeSet" and js_data.datascale != "z_score" | |
+ rows = rows.concat(Extra_Stat_Table_Rows) | |
+ rows | |
+ | |
add = -> | |
trait = $("input[name=trait_hmac]").val() | |
console.log("trait is:", trait) | |
@@ -136,7 +145,7 @@ $ -> | |
update_stat_values = (sample_sets)-> | |
show_effects = $(".tab-pane.active").attr("id") == "stats_tab" | |
for category in ['samples_primary', 'samples_other', 'samples_all'] | |
- for row in Stat_Table_Rows | |
+ for row in stat_table_rows() | |
console.log("Calling change_stats_value") | |
change_stats_value(sample_sets, category, row.vn, row.digits, show_effects) | |
@@ -152,7 +161,13 @@ $ -> | |
make_table = -> | |
header = "<thead><tr><th> </th>" | |
console.log("js_data.sample_group_types:", js_data.sample_group_types) | |
- for own key, value of js_data.sample_group_types | |
+ non_empty_group_types = {} | |
+ if js_data.sample_lists.length == 1 | |
+ non_empty_group_types['samples_all'] = js_data.sample_group_types['samples_all'] | |
+ else | |
+ non_empty_group_types = js_data.sample_group_types | |
+ console.log("non-empty sample_group_types:", non_empty_group_types) | |
+ for own key, value of non_empty_group_types | |
console.log("aa key:", key) | |
console.log("aa value:", value) | |
the_id = process_id("column", key) | |
@@ -163,15 +178,15 @@ $ -> | |
#console.log("rows are:", rows) | |
the_rows = "<tbody>" | |
#console.log("length of rows:", rows.length) | |
- for row in Stat_Table_Rows | |
+ for row in stat_table_rows() | |
console.log("rowing") | |
row_line = """<tr>""" | |
if row.url? | |
row_line += """<td id="#{ row.vn }"><a href="#{row.url }">#{ row.pretty }</a></td>""" | |
else | |
row_line += """<td id="#{ row.vn }">#{ row.pretty }</td>""" | |
- console.log("box - js_data.sample_group_types:", js_data.sample_group_types) | |
- for own key, value of js_data.sample_group_types | |
+ console.log("box - sample_group_types:", non_empty_group_types) | |
+ for own key, value of non_empty_group_types | |
console.log("apple key:", key) | |
the_id = process_id(key, row.vn) | |
console.log("the_id:", the_id) | |
@@ -199,9 +214,9 @@ $ -> | |
edit_data_change = -> | |
already_seen = {} | |
sample_sets = | |
- samples_primary: new Stats([]) | |
- samples_other: new Stats([]) | |
- samples_all: new Stats([]) | |
+ samples_primary: new Stats([], js_data.datascale) | |
+ samples_other: new Stats([], js_data.datascale) | |
+ samples_all: new Stats([], js_data.datascale) | |
root.selected_samples = # maps: sample name -> value | |
samples_primary: {} | |
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js | |
index 302d5ec..9563d1c 100755 | |
--- a/wqflask/wqflask/static/new/javascript/show_trait.js | |
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js | |
@@ -1,8 +1,8 @@ | |
-// Generated by CoffeeScript 1.8.0 | |
+// Generated by CoffeeScript 1.9.2 | |
(function() { | |
- var Stat_Table_Rows, is_number, | |
- __hasProp = {}.hasOwnProperty, | |
- __slice = [].slice; | |
+ var Common_Stat_Table_Rows, Extra_Stat_Table_Rows, is_number, | |
+ hasProp = {}.hasOwnProperty, | |
+ slice = [].slice; | |
console.log("start_b"); | |
@@ -10,7 +10,7 @@ | |
return !isNaN((o - 0) && o !== null); | |
}; | |
- Stat_Table_Rows = [ | |
+ Common_Stat_Table_Rows = [ | |
{ | |
vn: "n_of_samples", | |
pretty: "N of Samples", | |
@@ -39,9 +39,13 @@ | |
vn: "max", | |
pretty: "Maximum", | |
digits: 2 | |
- }, { | |
+ } | |
+ ]; | |
+ | |
+ Extra_Stat_Table_Rows = [ | |
+ { | |
vn: "range", | |
- pretty: "Range (log2)", | |
+ pretty: "Range" + (js_data.datascale === "linear" ? "" : " (log2)"), | |
digits: 2 | |
}, { | |
vn: "range_fold", | |
@@ -56,7 +60,15 @@ | |
]; | |
$(function() { | |
- var add, 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, open_trait_selection, populate_sample_attributes_values_dropdown, process_id, redraw_bar_chart, redraw_histogram, redraw_prob_plot, reset_samples_table, sample_group_types, sample_lists, show_hide_outliers, stats_mdp_change, update_stat_values; | |
+ var add, 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, open_trait_selection, populate_sample_attributes_values_dropdown, process_id, redraw_bar_chart, redraw_histogram, redraw_prob_plot, reset_samples_table, sample_group_types, sample_lists, show_hide_outliers, stat_table_rows, stats_mdp_change, update_stat_values; | |
+ stat_table_rows = function() { | |
+ var rows; | |
+ rows = Common_Stat_Table_Rows; | |
+ if (js_data.dataset_type === "ProbeSet" && js_data.datascale !== "z_score") { | |
+ rows = rows.concat(Extra_Stat_Table_Rows); | |
+ } | |
+ return rows; | |
+ }; | |
add = function() { | |
var trait; | |
trait = $("input[name=trait_hmac]").val(); | |
@@ -91,12 +103,12 @@ | |
})(this)); | |
}; | |
hide_tabs = function(start) { | |
- var x, _i, _results; | |
- _results = []; | |
- for (x = _i = start; start <= 10 ? _i <= 10 : _i >= 10; x = start <= 10 ? ++_i : --_i) { | |
- _results.push($("#stats_tabs" + x).hide()); | |
+ var i, ref, results, x; | |
+ results = []; | |
+ for (x = i = ref = start; ref <= 10 ? i <= 10 : i >= 10; x = ref <= 10 ? ++i : --i) { | |
+ results.push($("#stats_tabs" + x).hide()); | |
} | |
- return _results; | |
+ return results; | |
}; | |
stats_mdp_change = function() { | |
var selected; | |
@@ -133,36 +145,37 @@ | |
} | |
}; | |
update_stat_values = function(sample_sets) { | |
- var category, row, show_effects, _i, _len, _ref, _results; | |
+ var category, i, len, ref, results, row, show_effects; | |
show_effects = $(".tab-pane.active").attr("id") === "stats_tab"; | |
- _ref = ['samples_primary', 'samples_other', 'samples_all']; | |
- _results = []; | |
- for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
- category = _ref[_i]; | |
- _results.push((function() { | |
- var _j, _len1, _results1; | |
- _results1 = []; | |
- for (_j = 0, _len1 = Stat_Table_Rows.length; _j < _len1; _j++) { | |
- row = Stat_Table_Rows[_j]; | |
+ ref = ['samples_primary', 'samples_other', 'samples_all']; | |
+ results = []; | |
+ for (i = 0, len = ref.length; i < len; i++) { | |
+ category = ref[i]; | |
+ results.push((function() { | |
+ var j, len1, ref1, results1; | |
+ ref1 = stat_table_rows(); | |
+ results1 = []; | |
+ for (j = 0, len1 = ref1.length; j < len1; j++) { | |
+ row = ref1[j]; | |
console.log("Calling change_stats_value"); | |
- _results1.push(change_stats_value(sample_sets, category, row.vn, row.digits, show_effects)); | |
+ results1.push(change_stats_value(sample_sets, category, row.vn, row.digits, show_effects)); | |
} | |
- return _results1; | |
+ return results1; | |
})()); | |
} | |
- return _results; | |
+ return results; | |
}; | |
redraw_histogram = function() { | |
var x; | |
return root.histogram.redraw((function() { | |
- var _i, _len, _ref, _results; | |
- _ref = _.values(root.selected_samples[root.histogram_group]); | |
- _results = []; | |
- for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
- x = _ref[_i]; | |
- _results.push(x.value); | |
+ var i, len, ref, results; | |
+ ref = _.values(root.selected_samples[root.histogram_group]); | |
+ results = []; | |
+ for (i = 0, len = ref.length; i < len; i++) { | |
+ x = ref[i]; | |
+ results.push(x.value); | |
} | |
- return _results; | |
+ return results; | |
})()); | |
}; | |
redraw_bar_chart = function() { | |
@@ -172,13 +185,19 @@ | |
return root.redraw_prob_plot_impl(root.selected_samples, root.prob_plot_group); | |
}; | |
make_table = function() { | |
- var header, key, row, row_line, table, the_id, the_rows, value, _i, _len, _ref, _ref1; | |
+ var header, i, key, len, non_empty_group_types, ref, row, row_line, table, the_id, the_rows, value; | |
header = "<thead><tr><th> </th>"; | |
console.log("js_data.sample_group_types:", js_data.sample_group_types); | |
- _ref = js_data.sample_group_types; | |
- for (key in _ref) { | |
- if (!__hasProp.call(_ref, key)) continue; | |
- value = _ref[key]; | |
+ non_empty_group_types = {}; | |
+ if (js_data.sample_lists.length === 1) { | |
+ non_empty_group_types['samples_all'] = js_data.sample_group_types['samples_all']; | |
+ } else { | |
+ non_empty_group_types = js_data.sample_group_types; | |
+ } | |
+ console.log("non-empty sample_group_types:", non_empty_group_types); | |
+ for (key in non_empty_group_types) { | |
+ if (!hasProp.call(non_empty_group_types, key)) continue; | |
+ value = non_empty_group_types[key]; | |
console.log("aa key:", key); | |
console.log("aa value:", value); | |
the_id = process_id("column", key); | |
@@ -187,8 +206,9 @@ | |
header += "</thead>"; | |
console.log("windex header is:", header); | |
the_rows = "<tbody>"; | |
- for (_i = 0, _len = Stat_Table_Rows.length; _i < _len; _i++) { | |
- row = Stat_Table_Rows[_i]; | |
+ ref = stat_table_rows(); | |
+ for (i = 0, len = ref.length; i < len; i++) { | |
+ row = ref[i]; | |
console.log("rowing"); | |
row_line = "<tr>"; | |
if (row.url != null) { | |
@@ -196,11 +216,10 @@ | |
} else { | |
row_line += "<td id=\"" + row.vn + "\">" + row.pretty + "</td>"; | |
} | |
- console.log("box - js_data.sample_group_types:", js_data.sample_group_types); | |
- _ref1 = js_data.sample_group_types; | |
- for (key in _ref1) { | |
- if (!__hasProp.call(_ref1, key)) continue; | |
- value = _ref1[key]; | |
+ console.log("box - sample_group_types:", non_empty_group_types); | |
+ for (key in non_empty_group_types) { | |
+ if (!hasProp.call(non_empty_group_types, key)) continue; | |
+ value = non_empty_group_types[key]; | |
console.log("apple key:", key); | |
the_id = process_id(key, row.vn); | |
console.log("the_id:", the_id); | |
@@ -216,13 +235,13 @@ | |
return $("#stats_table").append(table); | |
}; | |
process_id = function() { | |
- var processed, value, values, _i, _len; | |
- values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | |
+ var i, len, processed, value, values; | |
+ values = 1 <= arguments.length ? slice.call(arguments, 0) : []; | |
/* Make an id or a class valid javascript by, for example, eliminating spaces */ | |
processed = ""; | |
- for (_i = 0, _len = values.length; _i < _len; _i++) { | |
- value = values[_i]; | |
+ for (i = 0, len = values.length; i < len; i++) { | |
+ value = values[i]; | |
console.log("value:", value); | |
value = value.replace(" ", "_"); | |
if (processed.length) { | |
@@ -233,12 +252,12 @@ | |
return processed; | |
}; | |
edit_data_change = function() { | |
- var already_seen, checkbox, checked, name, real_dict, real_value, real_variance, row, rows, sample_sets, table, tables, _i, _j, _len, _len1; | |
+ var already_seen, checkbox, checked, i, j, len, len1, name, real_dict, real_value, real_variance, row, rows, sample_sets, table, tables; | |
already_seen = {}; | |
sample_sets = { | |
- samples_primary: new Stats([]), | |
- samples_other: new Stats([]), | |
- samples_all: new Stats([]) | |
+ samples_primary: new Stats([], js_data.datascale), | |
+ samples_other: new Stats([], js_data.datascale), | |
+ samples_all: new Stats([], js_data.datascale) | |
}; | |
root.selected_samples = { | |
samples_primary: {}, | |
@@ -247,11 +266,11 @@ | |
}; | |
console.log("at beginning:", sample_sets); | |
tables = ['samples_primary', 'samples_other']; | |
- for (_i = 0, _len = tables.length; _i < _len; _i++) { | |
- table = tables[_i]; | |
+ for (i = 0, len = tables.length; i < len; i++) { | |
+ table = tables[i]; | |
rows = $("#" + table).find('tr'); | |
- for (_j = 0, _len1 = rows.length; _j < _len1; _j++) { | |
- row = rows[_j]; | |
+ for (j = 0, len1 = rows.length; j < len1; j++) { | |
+ row = rows[j]; | |
name = $(row).find('.edit_sample_sample_name').html(); | |
name = $.trim(name); | |
real_value = $(row).find('.edit_sample_value').val(); | |
@@ -319,26 +338,26 @@ | |
return "<option val=" + value + ">" + value + "</option>"; | |
}; | |
populate_sample_attributes_values_dropdown = function() { | |
- var attribute_info, key, sample_attributes, selected_attribute, value, _i, _len, _ref, _ref1, _results; | |
+ var attribute_info, i, key, len, ref, ref1, results, sample_attributes, selected_attribute, value; | |
console.log("in beginning of psavd"); | |
$('#attribute_values').empty(); | |
sample_attributes = {}; | |
- _ref = js_data.attribute_names; | |
- for (key in _ref) { | |
- if (!__hasProp.call(_ref, key)) continue; | |
- attribute_info = _ref[key]; | |
+ ref = js_data.attribute_names; | |
+ for (key in ref) { | |
+ if (!hasProp.call(ref, key)) continue; | |
+ attribute_info = ref[key]; | |
sample_attributes[attribute_info.name] = attribute_info.distinct_values; | |
} | |
console.log("[visa] attributes is:", sample_attributes); | |
selected_attribute = $('#exclude_menu').val().replace("_", " "); | |
console.log("selected_attribute is:", selected_attribute); | |
- _ref1 = sample_attributes[selected_attribute]; | |
- _results = []; | |
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | |
- value = _ref1[_i]; | |
- _results.push($(create_value_dropdown(value)).appendTo($('#attribute_values'))); | |
+ ref1 = sample_attributes[selected_attribute]; | |
+ results = []; | |
+ for (i = 0, len = ref1.length; i < len; i++) { | |
+ value = ref1[i]; | |
+ results.push($(create_value_dropdown(value)).appendTo($('#attribute_values'))); | |
} | |
- return _results; | |
+ return results; | |
}; | |
if (js_data.attribute_names.length > 0) { | |
populate_sample_attributes_values_dropdown(); | |
@@ -361,17 +380,17 @@ | |
}; | |
$('#exclude_group').click(block_by_attribute_value); | |
block_by_index = function() { | |
- var end_index, error, index, index_list, index_set, index_string, start_index, _i, _j, _k, _len, _len1, _ref, _results; | |
+ var end_index, error, i, index, index_list, index_set, index_string, j, k, len, len1, ref, ref1, ref2, results, start_index; | |
index_string = $('#remove_samples_field').val(); | |
index_list = []; | |
- _ref = index_string.split(","); | |
- for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
- index_set = _ref[_i]; | |
+ ref = index_string.split(","); | |
+ for (i = 0, len = ref.length; i < len; i++) { | |
+ index_set = ref[i]; | |
if (index_set.indexOf('-') !== -1) { | |
try { | |
start_index = parseInt(index_set.split("-")[0]); | |
end_index = parseInt(index_set.split("-")[1]); | |
- for (index = _j = start_index; start_index <= end_index ? _j <= end_index : _j >= end_index; index = start_index <= end_index ? ++_j : --_j) { | |
+ for (index = j = ref1 = start_index, ref2 = end_index; ref1 <= ref2 ? j <= ref2 : j >= ref2; index = ref1 <= ref2 ? ++j : --j) { | |
index_list.push(index); | |
} | |
} catch (_error) { | |
@@ -385,22 +404,22 @@ | |
} | |
} | |
console.log("index_list:", index_list); | |
- _results = []; | |
- for (_k = 0, _len1 = index_list.length; _k < _len1; _k++) { | |
- index = index_list[_k]; | |
+ results = []; | |
+ for (k = 0, len1 = index_list.length; k < len1; k++) { | |
+ index = index_list[k]; | |
if ($('#block_group').val() === "primary") { | |
console.log("block_group:", $('#block_group').val()); | |
console.log("row:", $('#Primary_' + index.toString())); | |
- _results.push($('#Primary_' + index.toString()).find('.trait_value_input').val("x")); | |
+ results.push($('#Primary_' + index.toString()).find('.trait_value_input').val("x")); | |
} else if ($('#block_group').val() === "other") { | |
console.log("block_group:", $('#block_group').val()); | |
console.log("row:", $('#Other_' + index.toString())); | |
- _results.push($('#Other_' + index.toString()).find('.trait_value_input').val("x")); | |
+ results.push($('#Other_' + index.toString()).find('.trait_value_input').val("x")); | |
} else { | |
- _results.push(void 0); | |
+ results.push(void 0); | |
} | |
} | |
- return _results; | |
+ return results; | |
}; | |
$('#block_by_index').click(block_by_index); | |
hide_no_value = function() { | |
@@ -437,17 +456,17 @@ | |
samples = []; | |
$('#' + table_name).find('.value_se').each((function(_this) { | |
return function(_index, element) { | |
- var attribute_info, key, row_data, _ref; | |
+ var attribute_info, key, ref, row_data; | |
row_data = {}; | |
row_data.name = $.trim($(element).find('.column_name-Sample').text()); | |
row_data.value = $(element).find('.edit_sample_value').val(); | |
if ($(element).find('.edit_sample_se').length !== -1) { | |
row_data.se = $(element).find('.edit_sample_se').val(); | |
} | |
- _ref = js_data.attribute_names; | |
- for (key in _ref) { | |
- if (!__hasProp.call(_ref, key)) continue; | |
- attribute_info = _ref[key]; | |
+ ref = js_data.attribute_names; | |
+ for (key in ref) { | |
+ if (!hasProp.call(ref, key)) continue; | |
+ attribute_info = ref[key]; | |
row_data[attribute_info.name] = $.trim($(element).find('.column_name-' + attribute_info.name.replace(" ", "_")).text()); | |
} | |
console.log("row_data is:", row_data); | |
diff --git a/wqflask/wqflask/static/new/javascript/stats.coffee b/wqflask/wqflask/static/new/javascript/stats.coffee | |
index bf79d6c..889d5fa 100755 | |
--- a/wqflask/wqflask/static/new/javascript/stats.coffee | |
+++ b/wqflask/wqflask/static/new/javascript/stats.coffee | |
@@ -1,5 +1,5 @@ | |
class Stats | |
- constructor: (@the_values) -> | |
+ constructor: (@the_values, @datascale=null) -> | |
add_value: (value) -> | |
@the_values.push(value) | |
@@ -47,9 +47,14 @@ class Stats | |
range: -> | |
return @max() - @min() | |
+ # returns the ratio of maximum and minimum values | |
range_fold: -> | |
- return Math.pow(2, @range()) | |
+ if @datascale == "log2" | |
+ return Math.pow(2, @max() - @min()) | |
+ return @max() / @min() | |
+ # for linear scale returns the difference between 3rd and 1st quartiles | |
+ # for log2 scales returns their ratio | |
interquartile: -> | |
length = @the_values.length | |
# Todo: Consider averaging q1 and a3 when the length is odd | |
@@ -57,8 +62,10 @@ class Stats | |
console.log("length is:", length) | |
q1 = @the_values[Math.floor(length * .25)] | |
q3 = @the_values[Math.floor(length * .75)] | |
- iq = q3 - q1 | |
- return Math.pow(2, iq) | |
+ if @datascale == "log2" | |
+ return Math.pow(2, q3) - Math.pow(2, q1) | |
+ else | |
+ return q3 - q1 | |
bxd_only = new Stats([3, 5, 7, 8]) | |
diff --git a/wqflask/wqflask/static/new/javascript/stats.js b/wqflask/wqflask/static/new/javascript/stats.js | |
index 203652f..d6e1419 100755 | |
--- a/wqflask/wqflask/static/new/javascript/stats.js | |
+++ b/wqflask/wqflask/static/new/javascript/stats.js | |
@@ -1,9 +1,10 @@ | |
-// Generated by CoffeeScript 1.8.0 | |
+// Generated by CoffeeScript 1.9.2 | |
var Stats, bxd_only; | |
Stats = (function() { | |
- function Stats(the_values) { | |
+ function Stats(the_values, datascale) { | |
this.the_values = the_values; | |
+ this.datascale = datascale != null ? datascale : null; | |
} | |
Stats.prototype.add_value = function(value) { | |
@@ -15,11 +16,11 @@ Stats = (function() { | |
}; | |
Stats.prototype.sum = function() { | |
- var total, value, _i, _len, _ref; | |
+ var i, len, ref, total, value; | |
total = 0; | |
- _ref = this.the_values; | |
- for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
- value = _ref[_i]; | |
+ ref = this.the_values; | |
+ for (i = 0, len = ref.length; i < len; i++) { | |
+ value = ref[i]; | |
total += value; | |
} | |
return total; | |
@@ -44,11 +45,11 @@ Stats = (function() { | |
}; | |
Stats.prototype.std_dev = function() { | |
- var step_a, step_b, sum, value, _i, _len, _ref; | |
+ var i, len, ref, step_a, step_b, sum, value; | |
sum = 0; | |
- _ref = this.the_values; | |
- for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
- value = _ref[_i]; | |
+ ref = this.the_values; | |
+ for (i = 0, len = ref.length; i < len; i++) { | |
+ value = ref[i]; | |
step_a = Math.pow(value - this.mean(), 2); | |
sum += step_a; | |
} | |
@@ -73,18 +74,24 @@ Stats = (function() { | |
}; | |
Stats.prototype.range_fold = function() { | |
- return Math.pow(2, this.range()); | |
+ if (this.datascale === "log2") { | |
+ return Math.pow(2, this.max() - this.min()); | |
+ } | |
+ return this.max() / this.min(); | |
}; | |
Stats.prototype.interquartile = function() { | |
- var iq, length, q1, q3; | |
+ var length, q1, q3; | |
length = this.the_values.length; | |
console.log("in interquartile the_values are:", this.the_values); | |
console.log("length is:", length); | |
q1 = this.the_values[Math.floor(length * .25)]; | |
q3 = this.the_values[Math.floor(length * .75)]; | |
- iq = q3 - q1; | |
- return Math.pow(2, iq); | |
+ if (this.datascale === "log2") { | |
+ return Math.pow(2, q3) - Math.pow(2, q1); | |
+ } else { | |
+ return q3 - q1; | |
+ } | |
}; | |
return Stats; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment