diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/show_trait/show_trait.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/show_trait.js | 2209 | ||||
-rw-r--r-- | wqflask/wqflask/static/output/Itvl_3kiKQR1g.jpeg | bin | 100480 -> 0 bytes | |||
-rw-r--r-- | wqflask/wqflask/static/output/Itvl_hNsk2rxO.jpeg | bin | 100480 -> 0 bytes | |||
-rw-r--r-- | wqflask/wqflask/templates/show_trait.html | 341 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait_edit_data.html | 169 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait_mapping_tools.html | 4 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait_transform_and_filter.html | 6 |
8 files changed, 1370 insertions, 1361 deletions
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 2955f69a..0d1ed345 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -168,6 +168,7 @@ class ShowTrait(object): hddn['maf'] = 0.01 hddn['compare_traits'] = [] hddn['export_data'] = "" + hddn['export_format'] = "excel" # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self self.hddn = hddn @@ -224,6 +225,7 @@ class ShowTrait(object): sample_lists = sample_lists, attribute_names = self.sample_groups[0].attributes, num_values = self.num_values, + qnorm_values = self.qnorm_vals, sample_column_width = sample_column_width, temp_uuid = self.temp_uuid) self.js_data = js_data diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 2f846642..74706f98 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -1,1195 +1,1194 @@ -// Generated by CoffeeScript 1.8.0 -(function() { - var Stat_Table_Rows, is_number, - __hasProp = {}.hasOwnProperty, - __slice = [].slice; - - console.log("start_b"); - - is_number = function(o) { - return !isNaN((o - 0) && o !== null); +var Stat_Table_Rows, is_number, + __hasProp = {}.hasOwnProperty, + __slice = [].slice; + +console.log("start_b"); + +is_number = function(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: 3 + }, { + vn: "median", + pretty: "Median", + digits: 3 + }, { + vn: "std_error", + pretty: "Standard Error (SE)", + digits: 3 + }, { + vn: "std_dev", + pretty: "Standard Deviation (SD)", + digits: 3 + }, { + vn: "min", + pretty: "Minimum", + digits: 2 + }, { + vn: "max", + pretty: "Maximum", + digits: 2 + }, { + vn: "range", + pretty: "Range (log2)", + digits: 3 + }, { + vn: "range_fold", + pretty: "Range (fold)", + digits: 3 + }, { + vn: "interquartile", + pretty: "Interquartile Range", + url: "http://www.genenetwork.org/glossary.html#Interquartile", + digits: 3 + }, { + vn: "skewness", + pretty: "Skewness", + digits: 3 + }, { + vn: "kurtosis", + pretty: "Kurtosis", + digits: 3 + } +]; + +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; +add = function() { + var trait; + trait = $("input[name=trait_hmac]").val(); + console.log("trait is:", trait); + return $.colorbox({ + href: "/collections/add?traits=" + trait + }); +}; +$('#add_to_collection').click(add); +sample_lists = js_data.sample_lists; +sample_group_types = js_data.sample_group_types; +d3.select("#select_compare_trait").on("click", (function(_this) { + return function() { + $('.scatter-matrix-container').remove(); + return open_trait_selection(); }; - - Stat_Table_Rows = [ - { - vn: "n_of_samples", - pretty: "N of Samples", - digits: 0 - }, { - vn: "mean", - pretty: "Mean", - digits: 3 - }, { - vn: "median", - pretty: "Median", - digits: 3 - }, { - vn: "std_error", - pretty: "Standard Error (SE)", - digits: 3 - }, { - vn: "std_dev", - pretty: "Standard Deviation (SD)", - digits: 3 - }, { - vn: "min", - pretty: "Minimum", - digits: 2 - }, { - vn: "max", - pretty: "Maximum", - digits: 2 - }, { - vn: "range", - pretty: "Range (log2)", - digits: 3 - }, { - vn: "range_fold", - pretty: "Range (fold)", - digits: 3 - }, { - vn: "interquartile", - pretty: "Interquartile Range", - url: "http://www.genenetwork.org/glossary.html#Interquartile", - digits: 3 - }, { - vn: "skewness", - pretty: "Skewness", - digits: 3 - }, { - vn: "kurtosis", - pretty: "Kurtosis", - digits: 3 - } - ]; - - $(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; - add = function() { - var trait; - trait = $("input[name=trait_hmac]").val(); - console.log("trait is:", trait); - return $.colorbox({ - href: "/collections/add?traits=" + trait +})(this)); +d3.select("#select_covariates").on("click", (function(_this) { + return function() { + return open_covariate_selection(); + }; +})(this)); +$("#remove_covariates").click(function () { + $("input[name=covariates]").val("") + $(".selected_covariates").val("") +}); +d3.select("#clear_compare_trait").on("click", (function(_this) { + return function() { + return $('.scatter-matrix-container').remove(); + }; +})(this)); +open_trait_selection = function() { + return $('#collections_holder').load('/collections/list?color_by_trait #collections_list', (function(_this) { + return function() { + $.colorbox({ + inline: true, + href: "#collections_holder", + onComplete: function(){ + console.log("before get script") + $.getScript("/static/new/javascript/get_traits_from_collection.js"); + console.log("after get script") + } }); + return $('a.collection_name').attr('onClick', 'return false'); }; - $('#add_to_collection').click(add); - sample_lists = js_data.sample_lists; - sample_group_types = js_data.sample_group_types; - d3.select("#select_compare_trait").on("click", (function(_this) { - return function() { - $('.scatter-matrix-container').remove(); - return open_trait_selection(); - }; - })(this)); - d3.select("#select_covariates").on("click", (function(_this) { - return function() { - return open_covariate_selection(); - }; - })(this)); - $("#remove_covariates").click(function () { - $("input[name=covariates]").val("") - $(".selected_covariates").val("") - }); - d3.select("#clear_compare_trait").on("click", (function(_this) { - return function() { - return $('.scatter-matrix-container').remove(); - }; - })(this)); - open_trait_selection = function() { - return $('#collections_holder').load('/collections/list?color_by_trait #collections_list', (function(_this) { - return function() { - $.colorbox({ - inline: true, - href: "#collections_holder", - onComplete: function(){ - console.log("before get script") - $.getScript("/static/new/javascript/get_traits_from_collection.js"); - console.log("after get script") - } - }); - return $('a.collection_name').attr('onClick', 'return false'); - }; - })(this)); - }; - open_covariate_selection = function() { - return $('#collections_holder').load('/collections/list #collections_list', (function(_this) { - return function() { - $.colorbox({ - inline: true, - href: "#collections_holder", - onComplete: function(){ - console.log("before get cov script") - $.getScript("/static/new/javascript/get_covariates_from_collection.js"); - console.log("after get cov script") - } - }); - return $('a.collection_name').attr('onClick', 'return false'); - }; - })(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()); - } - return _results; - }; - stats_mdp_change = function() { - var selected; - selected = $(this).val(); - hide_tabs(0); - return $("#stats_tabs" + selected).show(); - }; - change_stats_value = function(sample_sets, category, value_type, decimal_places, effects) { - 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; - current_value = parseFloat($(in_box)).toFixed(decimal_places); - 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) { - console.log("object:", $(id).html(the_value)); - if (effects) { - $(id).html(the_value).effect("highlight"); - } else { - $(id).html(the_value); + })(this)); +}; +open_covariate_selection = function() { + return $('#collections_holder').load('/collections/list #collections_list', (function(_this) { + return function() { + $.colorbox({ + inline: true, + href: "#collections_holder", + onComplete: function(){ + console.log("before get cov script") + $.getScript("/static/new/javascript/get_covariates_from_collection.js"); + console.log("after get cov script") } - } - if (title_value) { - return $(id).attr('title', title_value); - } + }); + return $('a.collection_name').attr('onClick', 'return false'); }; - update_stat_values = function(sample_sets) { - var category, row, show_effects, _i, _len, _ref, _results; - 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]; - console.log("Calling change_stats_value"); - _results1.push(change_stats_value(sample_sets, category, row.vn, row.digits, show_effects)); - } - return _results1; - })()); + })(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()); + } + return _results; +}; +stats_mdp_change = function() { + var selected; + selected = $(this).val(); + hide_tabs(0); + return $("#stats_tabs" + selected).show(); +}; +change_stats_value = function(sample_sets, category, value_type, decimal_places, effects) { + 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; + current_value = parseFloat($(in_box)).toFixed(decimal_places); + 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) { + console.log("object:", $(id).html(the_value)); + if (effects) { + $(id).html(the_value).effect("highlight"); + } else { + $(id).html(the_value); + } + } + if (title_value) { + return $(id).attr('title', title_value); + } +}; +update_stat_values = function(sample_sets) { + var category, row, show_effects, _i, _len, _ref, _results; + 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]; + console.log("Calling change_stats_value"); + _results1.push(change_stats_value(sample_sets, category, row.vn, row.digits, show_effects)); } - return _results; - }; - - update_histogram_width = function() { - num_bins = $('#histogram').find('g.trace.bars').find('g.point').length + return _results1; + })()); + } + return _results; +}; - if (num_bins < 10) { - width_update = { - width: 400 - } +update_histogram_width = function() { + num_bins = $('#histogram').find('g.trace.bars').find('g.point').length - Plotly.relayout('histogram', width_update) - } + if (num_bins < 10) { + width_update = { + width: 400 } - redraw_histogram = function() { - var x; - var _i, _len, _ref, data; - _ref = _.values(root.selected_samples[root.stats_group]); - var trait_vals = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - x = _ref[_i]; - trait_vals.push(x.value); - } - Plotly.restyle('histogram', 'x', [trait_vals]) - - update_histogram_width() - }; - - redraw_bar_chart = function() { - var x; - var _i, _len, _ref, data; - _ref = _.values(root.selected_samples[root.stats_group]); - names_and_values = [] - for (i = 0; i < _ref.length; i++){ - _ref[i]["name"] = Object.keys(root.selected_samples[root.stats_group])[i] - } - trait_vals = []; - trait_vars = []; - trait_samples = []; + Plotly.relayout('histogram', width_update) + } +} + +redraw_histogram = function() { + var x; + var _i, _len, _ref, data; + _ref = _.values(root.selected_samples[root.stats_group]); + var trait_vals = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + x = _ref[_i]; + trait_vals.push(x.value); + } + Plotly.restyle('histogram', 'x', [trait_vals]) + + update_histogram_width() +}; + +redraw_bar_chart = function() { + var x; + var _i, _len, _ref, data; + _ref = _.values(root.selected_samples[root.stats_group]); + names_and_values = [] + for (i = 0; i < _ref.length; i++){ + _ref[i]["name"] = Object.keys(root.selected_samples[root.stats_group])[i] + } + trait_vals = []; + trait_vars = []; + trait_samples = []; - function sortFunction(a, b) { - if (a.value === b.value) { - return 0; - } - else { - return (a.value < b.value) ? -1 : 1; - } - } + function sortFunction(a, b) { + if (a.value === b.value) { + return 0; + } + else { + return (a.value < b.value) ? -1 : 1; + } + } - if (root.bar_sort == "value") { - _ref.sort(sortFunction) - } + if (root.bar_sort == "value") { + _ref.sort(sortFunction) + } - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - x = _ref[_i]; - trait_samples.push(x.name) - trait_vals.push(x.value); - if (x["variance"] != undefined) { - trait_vars.push(x.variance); - } else{ - trait_vars.push(null) - } - } + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + x = _ref[_i]; + trait_samples.push(x.name) + trait_vals.push(x.value); + if (x["variance"] != undefined) { + trait_vars.push(x.variance); + } else{ + trait_vars.push(null) + } + } - root.bar_data[0]['y'] = trait_vals - root.bar_data[0]['error_y'] = { - type: 'data', - array: trait_vars, - visible: root.errors_exist - } - root.bar_data[0]['x'] = trait_samples - if (trait_vals.length < 256) { - Plotly.newPlot('bar_chart', root.bar_data, root.bar_layout); - } - }; + root.bar_data[0]['y'] = trait_vals + root.bar_data[0]['error_y'] = { + type: 'data', + array: trait_vars, + visible: root.errors_exist + } + root.bar_data[0]['x'] = trait_samples + if (trait_vals.length < 256) { + Plotly.newPlot('bar_chart', root.bar_data, root.bar_layout); + } +}; + +redraw_box_plot = function() { + var y_value_list = [] + for (var sample_group in root.selected_samples){ + var trait_sample_data = _.values(root.selected_samples[sample_group]) + var trait_vals = []; + for (i = 0, len = trait_sample_data.length; i < len; i++) { + this_sample_data = trait_sample_data[i]; + trait_vals.push(this_sample_data.value); + } + y_value_list.push(trait_vals) + } - redraw_box_plot = function() { - var y_value_list = [] - for (var sample_group in root.selected_samples){ - var trait_sample_data = _.values(root.selected_samples[sample_group]) - var trait_vals = []; - for (i = 0, len = trait_sample_data.length; i < len; i++) { - this_sample_data = trait_sample_data[i]; - trait_vals.push(this_sample_data.value); - } - y_value_list.push(trait_vals) + if (Object.keys(js_data.sample_group_types).length > 1) { + var update = { + y: y_value_list } - - if (Object.keys(js_data.sample_group_types).length > 1) { - var update = { - y: y_value_list - } - Plotly.restyle('box_plot', update, [0, 1, 2]) - } else { - var update = { - y: y_value_list - } - Plotly.restyle('box_plot', update) + Plotly.restyle('box_plot', update, [0, 1, 2]) + } else { + var update = { + y: y_value_list } + Plotly.restyle('box_plot', update) + } +} + +redraw_violin_plot = function() { + var y_value_list = [] + for (var sample_group in root.selected_samples){ + var trait_sample_data = _.values(root.selected_samples[sample_group]) + var trait_vals = []; + for (i = 0, len = trait_sample_data.length; i < len; i++) { + this_sample_data = trait_sample_data[i]; + trait_vals.push(this_sample_data.value); } + y_value_list.push(trait_vals) + } - redraw_violin_plot = function() { - var y_value_list = [] - for (var sample_group in root.selected_samples){ - var trait_sample_data = _.values(root.selected_samples[sample_group]) - var trait_vals = []; - for (i = 0, len = trait_sample_data.length; i < len; i++) { - this_sample_data = trait_sample_data[i]; - trait_vals.push(this_sample_data.value); - } - y_value_list.push(trait_vals) - } - - } +} - redraw_prob_plot = function() { - return root.redraw_prob_plot_impl(root.selected_samples, root.prob_plot_group); - }; +redraw_prob_plot = function() { + 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; - header = "<thead><tr><th style=\"text-align: right; padding-left: 5px;\">Statistic</th>"; - _ref = js_data.sample_group_types; - for (key in _ref) { - if (!__hasProp.call(_ref, key)) continue; - value = _ref[key]; - the_id = process_id("column", key); - if (Object.keys(_ref).length > 1) { - header += "<th id=\"" + the_id + "\" style=\"text-align: right; padding-left: 5px;\">" + value + "</th>"; - } else { - header += "<th id=\"" + the_id + "\" style=\"text-align: right; padding-left: 5px;\">Value</th>"; - } - } +make_table = function() { + var header, key, row, row_line, table, the_id, the_rows, value, _i, _len, _ref, _ref1; + header = "<thead><tr><th style=\"text-align: right; padding-left: 5px;\">Statistic</th>"; + _ref = js_data.sample_group_types; + for (key in _ref) { + if (!__hasProp.call(_ref, key)) continue; + value = _ref[key]; + the_id = process_id("column", key); + if (Object.keys(_ref).length > 1) { + header += "<th id=\"" + the_id + "\" style=\"text-align: right; padding-left: 5px;\">" + value + "</th>"; + } else { + header += "<th id=\"" + the_id + "\" style=\"text-align: right; padding-left: 5px;\">Value</th>"; + } + } - header += "</thead>"; - the_rows = "<tbody>"; - for (_i = 0, _len = Stat_Table_Rows.length; _i < _len; _i++) { - row = Stat_Table_Rows[_i]; - if ((row.vn == "range_fold" || row.vn == "range") && js_data.dataset_type == "Publish"){ - continue; - } - row_line = "<tr>"; - if (row.url != null) { - row_line += "<td id=\"" + row.vn + "\" align=\"right\"><a href=\"" + row.url + "\" style=\"color: #000000;\">" + row.pretty + "</a></td>"; + header += "</thead>"; + the_rows = "<tbody>"; + for (_i = 0, _len = Stat_Table_Rows.length; _i < _len; _i++) { + row = Stat_Table_Rows[_i]; + if ((row.vn == "range_fold" || row.vn == "range") && js_data.dataset_type == "Publish"){ + continue; + } + row_line = "<tr>"; + if (row.url != null) { + row_line += "<td id=\"" + row.vn + "\" align=\"right\"><a href=\"" + row.url + "\" style=\"color: #000000;\">" + row.pretty + "</a></td>"; + } else { + row_line += "<td id=\"" + row.vn + "\" align=\"right\">" + row.pretty + "</td>"; + } + _ref1 = js_data.sample_group_types; + for (key in _ref1) { + if (!__hasProp.call(_ref1, key)) continue; + value = _ref1[key]; + the_id = process_id(key, row.vn); + row_line += "<td id=\"" + the_id + "\" align=\"right\">N/A</td>"; + } + row_line += "</tr>"; + the_rows += row_line; + } + the_rows += "</tbody>"; + table = header + the_rows; + return $("#stats_table").append(table); +}; +process_id = function() { + var processed, value, values, _i, _len; + 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]; + console.log("value:", value); + value = value.replace(" ", "_"); + if (processed.length) { + processed += "-"; + } + processed += value; + } + 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; + already_seen = {}; + sample_sets = { + samples_primary: new Stats([]), + samples_other: new Stats([]), + samples_all: new Stats([]) + }; + root.selected_samples = { + samples_primary: {}, + samples_other: {}, + samples_all: {} + }; + console.log("at beginning:", sample_sets); + tables = ['samples_primary', 'samples_other']; + 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]; + name = $(row).find('.edit_sample_sample_name').html(); + name = $.trim(name); + real_value = $(row).find('.edit_sample_value').val(); + checkbox = $(row).find(".edit_sample_checkbox"); + checked = $(checkbox).prop('checked'); + if (checked && is_number(real_value) && real_value !== "") { + real_value = parseFloat(real_value); + sample_sets[table].add_value(real_value); + real_variance = $(row).find('.edit_sample_se').val(); + if (is_number(real_variance)) { + real_variance = parseFloat(real_variance); } else { - row_line += "<td id=\"" + row.vn + "\" align=\"right\">" + row.pretty + "</td>"; + real_variance = null; } - _ref1 = js_data.sample_group_types; - for (key in _ref1) { - if (!__hasProp.call(_ref1, key)) continue; - value = _ref1[key]; - the_id = process_id(key, row.vn); - row_line += "<td id=\"" + the_id + "\" align=\"right\">N/A</td>"; + real_dict = { + value: real_value, + variance: real_variance + }; + root.selected_samples[table][name] = real_dict; + if (!(name in already_seen)) { + sample_sets['samples_all'].add_value(real_value); + root.selected_samples['samples_all'][name] = real_dict; + already_seen[name] = true; } - row_line += "</tr>"; - the_rows += row_line; } - the_rows += "</tbody>"; - table = header + the_rows; - return $("#stats_table").append(table); - }; - process_id = function() { - var processed, value, values, _i, _len; - 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]; - console.log("value:", value); - value = value.replace(" ", "_"); - if (processed.length) { - processed += "-"; - } - processed += value; + } + } + console.log("towards end:", sample_sets); + update_stat_values(sample_sets); + + if ($('#histogram').hasClass('js-plotly-plot')){ + console.log("redrawing histogram"); + redraw_histogram(); + } + if ($('#bar_chart').hasClass('js-plotly-plot')){ + console.log("redrawing bar chart"); + redraw_bar_chart(); + } + if ($('#box_plot').hasClass('js-plotly-plot')){ + console.log("redrawing box plot"); + redraw_box_plot(); + } + if ($('#violin_plot').hasClass('js-plotly-plot')){ + console.log("redrawing violin plot"); + redraw_violin_plot(); + } + if ($('#prob_plot_div').hasClass('js-plotly-plot')){ + console.log("redrawing probability plot"); + return redraw_prob_plot(); + } +}; +show_hide_outliers = function() { + var label; + console.log("FOOBAR in beginning of show_hide_outliers"); + label = $('#show_hide_outliers').val(); + console.log("lable is:", label); + if (label === "Hide Outliers") { + return $('#show_hide_outliers').val("Show Outliers"); + } else if (label === "Show Outliers") { + console.log("Found Show Outliers"); + $('#show_hide_outliers').val("Hide Outliers"); + return console.log("Should be now Hide Outliers"); + } +}; +on_corr_method_change = function() { + var corr_method; + corr_method = $('select[name=corr_type]').val(); + console.log("corr_method is:", corr_method); + $('.correlation_desc').hide(); + $('#' + corr_method + "_r_desc").show().effect("highlight"); + if (corr_method === "lit") { + return $("#corr_sample_method").hide(); + } else { + return $("#corr_sample_method").show(); + } +}; +$('select[name=corr_type]').change(on_corr_method_change); + +submit_special = function(url) { + $("#trait_data_form").attr("action", url); + return $("#trait_data_form").submit(); +}; + +submit_corr = function(){ + var url; + url = "/corr_compute"; + return submit_special(url); +}; + +$(".corr_compute").on("click", (function(_this) { + return function() { + var url; + url = "/corr_compute"; + return submit_special(url); + }; +})(this)); + +create_value_dropdown = function(value) { + 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; + 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]; + 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'))); + } + return _results; +}; +if (js_data.attribute_names.length > 0) { + populate_sample_attributes_values_dropdown(); +} +$('#exclude_menu').change(populate_sample_attributes_values_dropdown); +block_by_attribute_value = function() { + var attribute_name, cell_class, exclude_by_value; + attribute_name = $('#exclude_menu').val(); + exclude_by_value = $('#attribute_values').val(); + cell_class = ".column_name-" + attribute_name; + return $(cell_class).each((function(_this) { + return function(index, element) { + var row; + if ($.trim($(element).text()) === exclude_by_value) { + row = $(element).parent('tr'); + return $(row).find(".trait_value_input").val("x"); } - 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; - already_seen = {}; - sample_sets = { - samples_primary: new Stats([]), - samples_other: new Stats([]), - samples_all: new Stats([]) - }; - root.selected_samples = { - samples_primary: {}, - samples_other: {}, - samples_all: {} - }; - console.log("at beginning:", sample_sets); - tables = ['samples_primary', 'samples_other']; - 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]; - name = $(row).find('.edit_sample_sample_name').html(); - name = $.trim(name); - real_value = $(row).find('.edit_sample_value').val(); - checkbox = $(row).find(".edit_sample_checkbox"); - checked = $(checkbox).prop('checked'); - if (checked && is_number(real_value) && real_value !== "") { - real_value = parseFloat(real_value); - sample_sets[table].add_value(real_value); - real_variance = $(row).find('.edit_sample_se').val(); - if (is_number(real_variance)) { - real_variance = parseFloat(real_variance); - } else { - real_variance = null; - } - real_dict = { - value: real_value, - variance: real_variance - }; - root.selected_samples[table][name] = real_dict; - if (!(name in already_seen)) { - sample_sets['samples_all'].add_value(real_value); - root.selected_samples['samples_all'][name] = real_dict; - already_seen[name] = true; - } - } + })(this)); +}; +$('#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; + 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]; + 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) { + index_list.push(index); } + } catch (_error) { + error = _error; + alert("Syntax error"); } - console.log("towards end:", sample_sets); - update_stat_values(sample_sets); - - if ($('#histogram').hasClass('js-plotly-plot')){ - console.log("redrawing histogram"); - redraw_histogram(); - } - if ($('#bar_chart').hasClass('js-plotly-plot')){ - console.log("redrawing bar chart"); - redraw_bar_chart(); - } - if ($('#box_plot').hasClass('js-plotly-plot')){ - console.log("redrawing box plot"); - redraw_box_plot(); - } - if ($('#violin_plot').hasClass('js-plotly-plot')){ - console.log("redrawing violin plot"); - redraw_violin_plot(); + } else { + index = parseInt(index_set); + console.log("index:", index); + index_list.push(index); + } + } + console.log("index_list:", index_list); + _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")); + } 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")); + } else { + _results.push(void 0); + } + } + return _results; +}; +$('#block_by_index').click(block_by_index); +hide_no_value = function() { + return $('.value_se').each((function(_this) { + return function(_index, element) { + if ($(element).find('.trait_value_input').val() === 'x') { + return $(element).hide(); } - if ($('#prob_plot_div').hasClass('js-plotly-plot')){ - console.log("redrawing probability plot"); - return redraw_prob_plot(); + }; + })(this)); +}; +$('#hide_no_value').click(hide_no_value); +block_outliers = function() { + return $('.outlier').each((function(_this) { + return function(_index, element) { + return $(element).find('.trait_value_input').val('x'); + }; + })(this)); +}; +$('#block_outliers').click(block_outliers); +reset_samples_table = function() { + $('input[name="transform"]').val(""); + return $('.trait_value_input').each((function(_this) { + return function(_index, element) { + console.log("value is:", $(element).val()); + $(element).val($(element).data('value')); + console.log("data-value is:", $(element).data('value')); + return $(element).parents('.value_se').show(); + }; + })(this)); +}; +$('.reset').click(reset_samples_table); + +log_normalize_data = function() { + return $('.trait_value_input').each((function(_this) { + return function(_index, element) { + current_value = parseFloat($(element).data("value")) + 1; + if(isNaN(current_value)) { + return current_value + } else { + $(element).val(Math.log2(current_value).toFixed(3)); + return Math.log2(current_value).toFixed(3) } }; - show_hide_outliers = function() { - var label; - console.log("FOOBAR in beginning of show_hide_outliers"); - label = $('#show_hide_outliers').val(); - console.log("lable is:", label); - if (label === "Hide Outliers") { - return $('#show_hide_outliers').val("Show Outliers"); - } else if (label === "Show Outliers") { - console.log("Found Show Outliers"); - $('#show_hide_outliers').val("Hide Outliers"); - return console.log("Should be now Hide Outliers"); + })(this)); +}; + +sqrt_normalize_data = function() { + return $('.edit_sample_value').each((function(_this) { + return function(_index, element) { + current_value = parseFloat($(element).data("value")) + 1; + if(isNaN(current_value)) { + return current_value + } else { + $(element).val(Math.sqrt(current_value).toFixed(3)); + return Math.sqrt(current_value).toFixed(3) } }; - on_corr_method_change = function() { - var corr_method; - corr_method = $('select[name=corr_type]').val(); - console.log("corr_method is:", corr_method); - $('.correlation_desc').hide(); - $('#' + corr_method + "_r_desc").show().effect("highlight"); - if (corr_method === "lit") { - return $("#corr_sample_method").hide(); + })(this)); +}; + +qnorm_data = function() { + return $('.edit_sample_value').each((function(_this) { + return function(_index, element) { + current_value = parseFloat($(element).data("value")) + 1; + if(isNaN(current_value)) { + return current_value } else { - return $("#corr_sample_method").show(); + $(element).val($(element).data("qnorm")); + return $(element).data("qnorm"); } }; - $('select[name=corr_type]').change(on_corr_method_change); + })(this)); +}; + +normalize_data = function() { + if ($('#norm_method option:selected').val() == 'log2'){ + if ($('input[name="transform"]').val() != "log2") { + log_normalize_data() + $('input[name="transform"]').val("log2") + } + } + else if ($('#norm_method option:selected').val() == 'sqrt'){ + if ($('input[name="transform"]').val() != "sqrt") { + sqrt_normalize_data() + $('input[name="transform"]').val("sqrt") + } + } + else if ($('#norm_method option:selected').val() == 'qnorm'){ + if ($('input[name="transform"]').val() != "qnorm") { + qnorm_data() + $('input[name="transform"]').val("qnorm") + } + } +} - submit_special = function(url) { - $("#trait_data_form").attr("action", url); - return $("#trait_data_form").submit(); - }; +$('#normalize').click(normalize_data); - submit_corr = function(){ - var url; - url = "/corr_compute"; - return submit_special(url); - }; - - $(".corr_compute").on("click", (function(_this) { - return function() { - var url; - url = "/corr_compute"; - return submit_special(url); - }; - })(this)); - - create_value_dropdown = function(value) { - return "<option val=" + value + ">" + value + "</option>"; +switch_qnorm_data = function() { + return $('.trait_value_input').each((function(_this) { + return function(_index, element) { + transform_val = $(element).data('transform') + if (transform_val != "") { + $(element).val(transform_val.toFixed(3)); + } + return transform_val }; - populate_sample_attributes_values_dropdown = function() { - var attribute_info, key, sample_attributes, selected_attribute, value, _i, _len, _ref, _ref1, _results; - console.log("in beginning of psavd"); - $('#attribute_values').empty(); - sample_attributes = {}; + })(this)); +}; +$('#qnorm').click(switch_qnorm_data); +get_sample_table_data = function(table_name) { + var samples; + samples = []; + $('#' + table_name).find('.value_se').each((function(_this) { + return function(_index, element) { + var attribute_info, key, row_data, _ref; + 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]; - 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'))); + row_data[attribute_info.name] = $.trim($(element).find('.column_name-' + attribute_info.name.replace(" ", "_")).text()); } - return _results; - }; - if (js_data.attribute_names.length > 0) { - populate_sample_attributes_values_dropdown(); - } - $('#exclude_menu').change(populate_sample_attributes_values_dropdown); - block_by_attribute_value = function() { - var attribute_name, cell_class, exclude_by_value; - attribute_name = $('#exclude_menu').val(); - exclude_by_value = $('#attribute_values').val(); - cell_class = ".column_name-" + attribute_name; - return $(cell_class).each((function(_this) { - return function(index, element) { - var row; - if ($.trim($(element).text()) === exclude_by_value) { - row = $(element).parent('tr'); - return $(row).find(".trait_value_input").val("x"); - } - }; - })(this)); + console.log("row_data is:", row_data); + return samples.push(row_data); }; - $('#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; - 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]; - 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) { - index_list.push(index); - } - } catch (_error) { - error = _error; - alert("Syntax error"); - } - } else { - index = parseInt(index_set); - console.log("index:", index); - index_list.push(index); - } - } - console.log("index_list:", index_list); - _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")); - } 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")); - } else { - _results.push(void 0); - } - } - return _results; - }; - $('#block_by_index').click(block_by_index); - hide_no_value = function() { - return $('.value_se').each((function(_this) { - return function(_index, element) { - if ($(element).find('.trait_value_input').val() === 'x') { - return $(element).hide(); - } - }; - })(this)); - }; - $('#hide_no_value').click(hide_no_value); - block_outliers = function() { - return $('.outlier').each((function(_this) { - return function(_index, element) { - return $(element).find('.trait_value_input').val('x'); - }; - })(this)); - }; - $('#block_outliers').click(block_outliers); - reset_samples_table = function() { - $('input[name="transform"]').val(""); - return $('.trait_value_input').each((function(_this) { - return function(_index, element) { - console.log("value is:", $(element).val()); - $(element).val($(element).data('value')); - console.log("data-value is:", $(element).data('value')); - return $(element).parents('.value_se').show(); - }; - })(this)); - }; - $('#reset').click(reset_samples_table); - - log_normalize_data = function() { - return $('.trait_value_input').each((function(_this) { - return function(_index, element) { - current_value = parseFloat($(element).data("value")) + 1; - if(isNaN(current_value)) { - return current_value - } else { - $(element).val(Math.log2(current_value).toFixed(3)); - return Math.log2(current_value).toFixed(3) - } - }; - })(this)); - }; - - sqrt_normalize_data = function() { - return $('.edit_sample_value').each((function(_this) { - return function(_index, element) { - current_value = parseFloat($(element).data("value")) + 1; - if(isNaN(current_value)) { - return current_value - } else { - $(element).val(Math.sqrt(current_value).toFixed(3)); - return Math.sqrt(current_value).toFixed(3) - } - }; - })(this)); - }; - - qnorm_data = function() { - return $('.edit_sample_value').each((function(_this) { - return function(_index, element) { - current_value = parseFloat($(element).data("value")) + 1; - if(isNaN(current_value)) { - return current_value - } else { - $(element).val($(element).data("qnorm")); - return $(element).data("qnorm"); - } - }; - })(this)); - }; - - normalize_data = function() { - if ($('#norm_method option:selected').val() == 'log2'){ - if ($('input[name="transform"]').val() != "log2") { - log_normalize_data() - $('input[name="transform"]').val("log2") - } + })(this)); + return samples; +}; +export_sample_table_data = function() { + var format, json_sample_data, sample_data; + sample_data = {}; + sample_data.primary_samples = get_sample_table_data('samples_primary'); + sample_data.other_samples = get_sample_table_data('samples_other'); + console.log("sample_data is:", sample_data); + json_sample_data = JSON.stringify(sample_data); + console.log("json_sample_data is:", json_sample_data); + $('input[name=export_data]').val(json_sample_data); + console.log("export_data is", $('input[name=export_data]').val()); + format = $('input[name=export_format]').val(); + if (format === "excel") { + $('#trait_data_form').attr('action', '/export_trait_excel'); + } else { + $('#trait_data_form').attr('action', '/export_trait_csv'); + } + console.log("action is:", $('#trait_data_form').attr('action')); + return $('#trait_data_form').submit(); +}; + +$('.export_format').change(function() { + $('input[name=export_format]').val( this.value ); + $('.export_format').val( this.value ); +}); + +$('.export').click(export_sample_table_data); +console.log("before registering block_outliers"); +$('#block_outliers').click(block_outliers); +console.log("after registering block_outliers"); +_.mixin(_.str.exports()); + +get_sample_vals = function(sample_list) { + var sample; + return this.sample_vals = (function() { + var i, len, results; + results = []; + for (i = 0, len = sample_list.length; i < len; i++) { + sample = sample_list[i]; + if (sample.value !== null) { + results.push(sample.value); } - else if ($('#norm_method option:selected').val() == 'sqrt'){ - if ($('input[name="transform"]').val() != "sqrt") { - sqrt_normalize_data() - $('input[name="transform"]').val("sqrt") - } + } + return results; + })(); +}; + +get_sample_errors = function(sample_list) { + var sample; + return this.sample_vals = (function() { + var i, len, results; + variance_exists = false; + results = []; + for (i = 0, len = sample_list.length; i < len; i++) { + sample = sample_list[i]; + if (sample.variance !== null) { + results.push(sample.variance); + variance_exists = true; } - else if ($('#norm_method option:selected').val() == 'qnorm'){ - if ($('input[name="transform"]').val() != "qnorm") { - qnorm_data() - $('input[name="transform"]').val("qnorm") - } + } + return [results, variance_exists]; + })(); +}; + +get_sample_names = function(sample_list) { + var sample; + return this.sample_names = (function() { + var i, len, results; + results = []; + for (i = 0, len = sample_list.length; i < len; i++) { + sample = sample_list[i]; + if (sample.value !== null) { + results.push(sample.name); } } + return results; + })(); +}; - $('#normalize').click(normalize_data); +root.stats_group = 'samples_primary'; - switch_qnorm_data = function() { - return $('.trait_value_input').each((function(_this) { - return function(_index, element) { - transform_val = $(element).data('transform') - if (transform_val != "") { - $(element).val(transform_val.toFixed(3)); - } - return transform_val - }; - })(this)); - }; - $('#qnorm').click(switch_qnorm_data); - get_sample_table_data = function(table_name) { - var samples; - samples = []; - $('#' + table_name).find('.value_se').each((function(_this) { - return function(_index, element) { - var attribute_info, key, row_data, _ref; - 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]; - row_data[attribute_info.name] = $.trim($(element).find('.column_name-' + attribute_info.name.replace(" ", "_")).text()); - } - console.log("row_data is:", row_data); - return samples.push(row_data); - }; - })(this)); - return samples; - }; - export_sample_table_data = function() { - var format, json_sample_data, sample_data; - sample_data = {}; - sample_data.primary_samples = get_sample_table_data('samples_primary'); - sample_data.other_samples = get_sample_table_data('samples_other'); - console.log("sample_data is:", sample_data); - json_sample_data = JSON.stringify(sample_data); - console.log("json_sample_data is:", json_sample_data); - $('input[name=export_data]').val(json_sample_data); - console.log("export_data is", $('input[name=export_data]').val()); - format = $('#export_format').val(); - if (format === "excel") { - $('#trait_data_form').attr('action', '/export_trait_excel'); - } else { - $('#trait_data_form').attr('action', '/export_trait_csv'); - } - console.log("action is:", $('#trait_data_form').attr('action')); - return $('#trait_data_form').submit(); - }; - $('#export').click(export_sample_table_data); - console.log("before registering block_outliers"); - $('#block_outliers').click(block_outliers); - console.log("after registering block_outliers"); - _.mixin(_.str.exports()); - - get_sample_vals = function(sample_list) { - var sample; - return this.sample_vals = (function() { - var i, len, results; - results = []; - for (i = 0, len = sample_list.length; i < len; i++) { - sample = sample_list[i]; - if (sample.value !== null) { - results.push(sample.value); - } - } - return results; - })(); - }; +if (Object.keys(js_data.sample_group_types).length > 1) { + full_sample_lists = [sample_lists[0], sample_lists[1], sample_lists[0].concat(sample_lists[1])] + sample_group_list = [js_data.sample_group_types['samples_primary'], js_data.sample_group_types['samples_other'], js_data.sample_group_types['samples_all']] +} else { + full_sample_lists = [sample_lists[0]] + sample_group_list = [js_data.sample_group_types['samples_primary']] +} - get_sample_errors = function(sample_list) { - var sample; - return this.sample_vals = (function() { - var i, len, results; - variance_exists = false; - results = []; - for (i = 0, len = sample_list.length; i < len; i++) { - sample = sample_list[i]; - if (sample.variance !== null) { - results.push(sample.variance); - variance_exists = true; - } - } - return [results, variance_exists]; - })(); - }; +// Define Plotly Options (for the options bar at the top of each figure) - get_sample_names = function(sample_list) { - var sample; - return this.sample_names = (function() { - var i, len, results; - results = []; - for (i = 0, len = sample_list.length; i < len; i++) { - sample = sample_list[i]; - if (sample.value !== null) { - results.push(sample.name); - } - } - return results; - })(); - }; +root.modebar_options = { + modeBarButtonsToRemove:['hoverClosest', 'hoverCompare', 'hoverClosestCartesian', 'hoverCompareCartesian', 'lasso2d', 'toggleSpikelines'] +} - root.stats_group = 'samples_primary'; +// Bar Chart - if (Object.keys(js_data.sample_group_types).length > 1) { - full_sample_lists = [sample_lists[0], sample_lists[1], sample_lists[0].concat(sample_lists[1])] - sample_group_list = [js_data.sample_group_types['samples_primary'], js_data.sample_group_types['samples_other'], js_data.sample_group_types['samples_all']] +root.errors_exist = get_sample_errors(sample_lists[0])[1] +var bar_trace = { + x: get_sample_names(sample_lists[0]), + y: get_sample_vals(sample_lists[0]), + error_y: { + type: 'data', + array: get_sample_errors(sample_lists[0])[0], + visible: root.errors_exist + }, + type: 'bar' +} + +root.bar_data = [bar_trace] + +positive_error_vals = [] +negative_error_vals = [] +for (i = 0;i < get_sample_vals(sample_lists[0]).length; i++){ + if (get_sample_errors(sample_lists[0])[0][i] != undefined) { + positive_error_vals.push(get_sample_vals(sample_lists[0])[i] + get_sample_errors(sample_lists[0])[0][i]) + negative_error_vals.push(get_sample_vals(sample_lists[0])[i] - get_sample_errors(sample_lists[0])[0][i]) } else { - full_sample_lists = [sample_lists[0]] - sample_group_list = [js_data.sample_group_types['samples_primary']] - } - - // Define Plotly Options (for the options bar at the top of each figure) - - root.modebar_options = { - modeBarButtonsToRemove:['hoverClosest', 'hoverCompare', 'hoverClosestCartesian', 'hoverCompareCartesian', 'lasso2d', 'toggleSpikelines'] + positive_error_vals.push(get_sample_vals(sample_lists[0])[i]) + negative_error_vals.push(get_sample_vals(sample_lists[0])[i]) } - - // Bar Chart - - root.errors_exist = get_sample_errors(sample_lists[0])[1] - var bar_trace = { - x: get_sample_names(sample_lists[0]), - y: get_sample_vals(sample_lists[0]), - error_y: { - type: 'data', - array: get_sample_errors(sample_lists[0])[0], - visible: root.errors_exist - }, - type: 'bar' +} + +// Calculate the y axis cutoff to avoid a situation where all bar variation is clustered at the top of the chart +min_y_val = Math.min(...negative_error_vals) +max_y_val = Math.max(...positive_error_vals) + +if (min_y_val == 0) { + range_top = max_y_val + Math.abs(max_y_val)*0.1 + range_bottom = 0; +} else { + range_top = max_y_val + Math.abs(max_y_val)*0.1 + range_bottom = min_y_val - Math.abs(min_y_val)*0.1 + if (min_y_val > 0) { + range_bottom = min_y_val - 0.1*Math.abs(min_y_val) + } else if (min_y_val < 0) { + range_bottom = min_y_val + 0.1*min_y_val + } else { + range_bottom = 0 } - - root.bar_data = [bar_trace] - - positive_error_vals = [] - negative_error_vals = [] - for (i = 0;i < get_sample_vals(sample_lists[0]).length; i++){ - if (get_sample_errors(sample_lists[0])[0][i] != undefined) { - positive_error_vals.push(get_sample_vals(sample_lists[0])[i] + get_sample_errors(sample_lists[0])[0][i]) - negative_error_vals.push(get_sample_vals(sample_lists[0])[i] - get_sample_errors(sample_lists[0])[0][i]) - } else { - positive_error_vals.push(get_sample_vals(sample_lists[0])[i]) - negative_error_vals.push(get_sample_vals(sample_lists[0])[i]) - } +} + +root.chart_range = [range_bottom, range_top] + +total_sample_count = 0 +for (i = 0, i < sample_lists.length; i++;) { + total_sample_count += get_sample_vals(sample_lists[i]).length +} + +if (js_data.num_values < 256) { + bar_chart_width = 25 * get_sample_vals(sample_lists[0]).length + + var layout = { + yaxis: { + range: root.chart_range, + }, + width: bar_chart_width, + height: 600, + margin: { + l: 50, + r: 30, + t: 30, + b: 80 } - - // Calculate the y axis cutoff to avoid a situation where all bar variation is clustered at the top of the chart - min_y_val = Math.min(...negative_error_vals) - max_y_val = Math.max(...positive_error_vals) - - if (min_y_val == 0) { - range_top = max_y_val + Math.abs(max_y_val)*0.1 - range_bottom = 0; + }; + root.bar_layout = layout + $('.bar_chart_tab').click(function() { + if ($('#bar_chart').hasClass('js-plotly-plot')){ + redraw_bar_chart(); } else { - range_top = max_y_val + Math.abs(max_y_val)*0.1 - range_bottom = min_y_val - Math.abs(min_y_val)*0.1 - if (min_y_val > 0) { - range_bottom = min_y_val - 0.1*Math.abs(min_y_val) - } else if (min_y_val < 0) { - range_bottom = min_y_val + 0.1*min_y_val - } else { - range_bottom = 0 - } + Plotly.newPlot('bar_chart', root.bar_data, root.bar_layout, root.modebar_options) } + }); +} - root.chart_range = [range_bottom, range_top] - - total_sample_count = 0 - for (i = 0, i < sample_lists.length; i++;) { - total_sample_count += get_sample_vals(sample_lists[i]).length - } - - if (js_data.num_values < 256) { - bar_chart_width = 25 * get_sample_vals(sample_lists[0]).length - - var layout = { +if (full_sample_lists.length > 1) { + root.box_layout = { + boxgap: 0.2, yaxis: { - range: root.chart_range, + range: [range_bottom, range_top], }, - width: bar_chart_width, - height: 600, + width: 600, + height: 500, margin: { l: 50, r: 30, t: 30, b: 80 } - }; - root.bar_layout = layout - $('.bar_chart_tab').click(function() { - if ($('#bar_chart').hasClass('js-plotly-plot')){ - redraw_bar_chart(); - } else { - Plotly.newPlot('bar_chart', root.bar_data, root.bar_layout, root.modebar_options) + }; + var trace1 = { + y: get_sample_vals(full_sample_lists[0]), + type: 'box', + name: sample_group_list[0], + boxpoints: 'Outliers', + jitter: 0.5, + whiskerwidth: 0.2, + fillcolor: 'cls', + pointpos: -3, + marker: { + color: 'rgb(0, 0, 255)', + size: 3 + }, + line: { + width: 1 } - }); } - - if (full_sample_lists.length > 1) { - root.box_layout = { - boxgap: 0.2, - yaxis: { - range: [range_bottom, range_top], - }, - width: 600, - height: 500, - margin: { - l: 50, - r: 30, - t: 30, - b: 80 - } - }; - var trace1 = { - y: get_sample_vals(full_sample_lists[0]), - type: 'box', - name: sample_group_list[0], - boxpoints: 'Outliers', - jitter: 0.5, - whiskerwidth: 0.2, - fillcolor: 'cls', - pointpos: -3, - marker: { - color: 'rgb(0, 0, 255)', - size: 3 - }, - line: { - width: 1 - } - } - var trace2 = { - y: get_sample_vals(full_sample_lists[1]), - type: 'box', - name: sample_group_list[1], - boxpoints: 'Outliers', - jitter: 0.5, - whiskerwidth: 0.2, - fillcolor: 'cls', - pointpos: -3, - marker: { - color: 'rgb(200, 0, 0)', - size: 3 - }, - line: { - width: 1 - } - } - var trace3 = { - y: get_sample_vals(full_sample_lists[2]), - type: 'box', - name: sample_group_list[2], - boxpoints: 'Outliers', - jitter: 0.5, - whiskerwidth: 0.2, - fillcolor: 'cls', - pointpos: -3, - marker: { - color: 'rgb(0, 104, 0)', - size: 3 - }, - line: { - width: 1 - } + var trace2 = { + y: get_sample_vals(full_sample_lists[1]), + type: 'box', + name: sample_group_list[1], + boxpoints: 'Outliers', + jitter: 0.5, + whiskerwidth: 0.2, + fillcolor: 'cls', + pointpos: -3, + marker: { + color: 'rgb(200, 0, 0)', + size: 3 + }, + line: { + width: 1 } - box_data = [trace1, trace2, trace3] - } else { - root.box_layout = { - yaxis: { - range: [range_bottom, range_top], - }, - width: 400, - height: 500, - margin: { - l: 50, - r: 30, - t: 30, - b: 80 - } - }; - box_data = [ - { - type: 'box', - y: get_sample_vals(full_sample_lists[0]), - name: sample_group_list[0], - boxpoints: 'Outliers', - jitter: 0.5, - whiskerwidth: 0.2, - fillcolor: 'cls', - pointpos: -3, - marker: { - size: 3 - }, - line: { - width: 1 - } - } - ] } - - box_obj = { - data: box_data, - layout: root.box_layout + var trace3 = { + y: get_sample_vals(full_sample_lists[2]), + type: 'box', + name: sample_group_list[2], + boxpoints: 'Outliers', + jitter: 0.5, + whiskerwidth: 0.2, + fillcolor: 'cls', + pointpos: -3, + marker: { + color: 'rgb(0, 104, 0)', + size: 3 + }, + line: { + width: 1 + } } - - $('.box_plot_tab').click(function() { - if ($('#box_plot').hasClass('js-plotly-plot')){ - redraw_box_plot(); - } else { - Plotly.newPlot('box_plot', box_obj, root.modebar_options); - } - }); - - // Violin Plot - - if (full_sample_lists.length > 1) { - root.violin_layout = { - title: "Violin Plot", - yaxis: { + box_data = [trace1, trace2, trace3] +} else { + root.box_layout = { + yaxis: { range: [range_bottom, range_top], - zeroline: false - }, - width: 600, - height: 500, - margin: { - l: 50, - r: 30, - t: 80, - b: 80 - } - }; - var trace1 = { - y: get_sample_vals(full_sample_lists[2]), - type: 'violin', - points: 'none', - box: { - visible: true - }, - line: { - color: 'green', - }, - meanline: { - visible: true - }, - name: sample_group_list[2], - x0: sample_group_list[2] - } - var trace2 = { - y: get_sample_vals(full_sample_lists[1]), - type: 'violin', - points: 'none', - box: { - visible: true - }, - line: { - color: 'green', - }, - meanline: { - visible: true - }, - name: sample_group_list[1], - x0: sample_group_list[1] + }, + width: 400, + height: 500, + margin: { + l: 50, + r: 30, + t: 30, + b: 80 } - var trace3 = { - y: get_sample_vals(full_sample_lists[0]), - type: 'violin', - points: 'none', - box: { - visible: true - }, - line: { - color: 'green', - }, - meanline: { - visible: true - }, - name: sample_group_list[0], - x0: sample_group_list[0] + }; + box_data = [ + { + type: 'box', + y: get_sample_vals(full_sample_lists[0]), + name: sample_group_list[0], + boxpoints: 'Outliers', + jitter: 0.5, + whiskerwidth: 0.2, + fillcolor: 'cls', + pointpos: -3, + marker: { + size: 3 + }, + line: { + width: 1 } - violin_data = [trace1, trace2, trace3] - } else { - root.violin_layout = { - title: "Violin Plot", - yaxis: { - range: [range_bottom, range_top], - zeroline: false - }, - width: 500, - height: 300, - margin: { - l: 50, - r: 30, - t: 80, - b: 80 - } - }; - violin_data = [ - { - y: get_sample_vals(full_sample_lists[0]), - type: 'violin', - points: 'none', - box: { - visible: true - }, - line: { - color: 'green', - }, - meanline: { - visible: true - }, - name: sample_group_list[0], - x0: sample_group_list[0] - } - ] - } - - violin_obj = { - data: violin_data, - layout: root.violin_layout - } - - $('.violin_plot_tab').click(function() { - if ($('#violin_plot').hasClass('js-plotly-plot')){ - redraw_violin_plot(); - } else { - Plotly.plot('violin_plot', violin_obj, root.modebar_options); } - }); - - // Histogram - var hist_trace = { - x: get_sample_vals(sample_lists[0]), - type: 'histogram' - }; - var data = [hist_trace]; - var layout = { - bargap: 0.05, - title: "Sample Values", - xaxis: {title: "Value"}, - yaxis: {title: "Count"}, + ] +} + +box_obj = { + data: box_data, + layout: root.box_layout +} + +$('.box_plot_tab').click(function() { + if ($('#box_plot').hasClass('js-plotly-plot')){ + redraw_box_plot(); + } else { + Plotly.newPlot('box_plot', box_obj, root.modebar_options); + } +}); + +// Violin Plot + +if (full_sample_lists.length > 1) { + root.violin_layout = { + title: "Violin Plot", + yaxis: { + range: [range_bottom, range_top], + zeroline: false + }, + width: 600, + height: 500, margin: { - l: 50, - r: 30, - t: 100, - b: 60 + l: 50, + r: 30, + t: 80, + b: 80 } }; - - $('.histogram_tab').click(function() { - if ($('#histogram').hasClass('js-plotly-plot')){ - redraw_histogram(); - update_histogram_width(); - } else { - Plotly.newPlot('histogram', data, layout, root.modebar_options) - update_histogram_width() - } - }); - - $('.histogram_samples_group').val(root.stats_group); - $('.histogram_samples_group').change(function() { - root.stats_group = $(this).val(); - return redraw_histogram(); - }); - - if (get_sample_vals(sample_lists[0]).length < 256) { - $('.bar_chart_samples_group').change(function() { - root.stats_group = $(this).val(); - return redraw_bar_chart(); - }); - root.bar_sort = "name" + var trace1 = { + y: get_sample_vals(full_sample_lists[2]), + type: 'violin', + points: 'none', + box: { + visible: true + }, + line: { + color: 'green', + }, + meanline: { + visible: true + }, + name: sample_group_list[2], + x0: sample_group_list[2] } - $('.sort_by_name').click(function() { - root.bar_sort = "name" - return redraw_bar_chart(); - }); - $('.sort_by_value').click(function() { - root.bar_sort = "value" - return redraw_bar_chart(); - }); - - root.prob_plot_group = 'samples_primary'; - $('.prob_plot_samples_group').val(root.prob_plot_group); - $('.prob_plot_tab').click(function() { - return redraw_prob_plot(); - }); - $('.prob_plot_samples_group').change(function() { - root.prob_plot_group = $(this).val(); - return redraw_prob_plot(); - }); - - function isEmpty( el ){ - return !$.trim(el.html()) + var trace2 = { + y: get_sample_vals(full_sample_lists[1]), + type: 'violin', + points: 'none', + box: { + visible: true + }, + line: { + color: 'green', + }, + meanline: { + visible: true + }, + name: sample_group_list[1], + x0: sample_group_list[1] } - - $('.stats_panel').click(function() { - if (isEmpty($('#stats_table'))){ - make_table(); - edit_data_change(); - } else { - edit_data_change(); + var trace3 = { + y: get_sample_vals(full_sample_lists[0]), + type: 'violin', + points: 'none', + box: { + visible: true + }, + line: { + color: 'green', + }, + meanline: { + visible: true + }, + name: sample_group_list[0], + x0: sample_group_list[0] + } + violin_data = [trace1, trace2, trace3] +} else { + root.violin_layout = { + title: "Violin Plot", + yaxis: { + range: [range_bottom, range_top], + zeroline: false + }, + width: 500, + height: 300, + margin: { + l: 50, + r: 30, + t: 80, + b: 80 } - }); - $('#edit_sample_lists').change(edit_data_change); - $('.edit_sample_value').change(edit_data_change); - $('#block_by_index').click(edit_data_change); - $('#exclude_group').click(edit_data_change); - $('#block_outliers').click(edit_data_change); - $('#reset').click(edit_data_change); - $('#qnorm').click(edit_data_change); - $('#normalize').click(edit_data_change); - return console.log("end"); + }; + violin_data = [ + { + y: get_sample_vals(full_sample_lists[0]), + type: 'violin', + points: 'none', + box: { + visible: true + }, + line: { + color: 'green', + }, + meanline: { + visible: true + }, + name: sample_group_list[0], + x0: sample_group_list[0] + } + ] +} + +violin_obj = { + data: violin_data, + layout: root.violin_layout +} + +$('.violin_plot_tab').click(function() { + if ($('#violin_plot').hasClass('js-plotly-plot')){ + redraw_violin_plot(); + } else { + Plotly.plot('violin_plot', violin_obj, root.modebar_options); + } +}); + +// Histogram +var hist_trace = { + x: get_sample_vals(sample_lists[0]), + type: 'histogram' +}; +var data = [hist_trace]; +var layout = { + bargap: 0.05, + title: "Sample Values", + xaxis: {title: "Value"}, + yaxis: {title: "Count"}, + margin: { + l: 50, + r: 30, + t: 100, + b: 60 + } +}; + +$('.histogram_tab').click(function() { + if ($('#histogram').hasClass('js-plotly-plot')){ + redraw_histogram(); + update_histogram_width(); + } else { + Plotly.newPlot('histogram', data, layout, root.modebar_options) + update_histogram_width() + } +}); + +$('.histogram_samples_group').val(root.stats_group); +$('.histogram_samples_group').change(function() { + root.stats_group = $(this).val(); + return redraw_histogram(); +}); + +if (get_sample_vals(sample_lists[0]).length < 256) { + $('.bar_chart_samples_group').change(function() { + root.stats_group = $(this).val(); + return redraw_bar_chart(); }); - - Number.prototype.countDecimals = function () { - if(Math.floor(this.valueOf()) === this.valueOf()) return 0; - return this.toString().split(".")[1].length || 0; + root.bar_sort = "name" +} +$('.sort_by_name').click(function() { + root.bar_sort = "name" + return redraw_bar_chart(); +}); +$('.sort_by_value').click(function() { + root.bar_sort = "value" + return redraw_bar_chart(); +}); + +root.prob_plot_group = 'samples_primary'; +$('.prob_plot_samples_group').val(root.prob_plot_group); +$('.prob_plot_tab').click(function() { + return redraw_prob_plot(); +}); +$('.prob_plot_samples_group').change(function() { + root.prob_plot_group = $(this).val(); + return redraw_prob_plot(); +}); + +function isEmpty( el ){ + return !$.trim(el.html()) +} + +$('.stats_panel').click(function() { + if (isEmpty($('#stats_table'))){ + make_table(); + edit_data_change(); + } else { + edit_data_change(); } - -}).call(this);
\ No newline at end of file +}); +$('#edit_sample_lists').change(edit_data_change); +$('.edit_sample_value').change(edit_data_change); +$('#block_by_index').click(edit_data_change); +$('#exclude_group').click(edit_data_change); +$('#block_outliers').click(edit_data_change); +$('#reset').click(edit_data_change); +$('#qnorm').click(edit_data_change); +$('#normalize').click(edit_data_change); + +Number.prototype.countDecimals = function () { + if(Math.floor(this.valueOf()) === this.valueOf()) return 0; + return this.toString().split(".")[1].length || 0; +}
\ No newline at end of file diff --git a/wqflask/wqflask/static/output/Itvl_3kiKQR1g.jpeg b/wqflask/wqflask/static/output/Itvl_3kiKQR1g.jpeg Binary files differdeleted file mode 100644 index bdd94651..00000000 --- a/wqflask/wqflask/static/output/Itvl_3kiKQR1g.jpeg +++ /dev/null diff --git a/wqflask/wqflask/static/output/Itvl_hNsk2rxO.jpeg b/wqflask/wqflask/static/output/Itvl_hNsk2rxO.jpeg Binary files differdeleted file mode 100644 index bdd94651..00000000 --- a/wqflask/wqflask/static/output/Itvl_hNsk2rxO.jpeg +++ /dev/null diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index f5e81060..9125b1ae 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -153,42 +153,21 @@ <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/noUiSlider/nouislider.js"></script> <script type="text/javascript" charset="utf-8"> - - function getValue(x) { - if (x.indexOf('input') >= 0) { - if ($(x).val() == 'x') { - return 'x' - } - else { - return parseFloat($(x).val()); - } - } - return parseFloat(x); - } - - jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - }; - - jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - if (x == 'x') { - return 1; - } - else if (y == 'x') { - return -1; - } - else { - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - } + $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $('input', td).prop('checked') ? '1' : '0'; + } ); }; - $(document).ready( function () { + $.fn.dataTable.ext.order['dom-input'] = function (settings, col) { + return this.api().column(col, { order: 'index' }).nodes().map(function (td, i) { + return $('input', td).val(); + }); + } + $(document).ready( function () { $('.panel-heading').click(function () { if ($(this).hasClass('collapsed')){ $(this).find('.glyphicon-chevron-down').removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up'); @@ -198,74 +177,250 @@ } }); - $('#samples_primary, #samples_other').find("tr.outlier").css('background-color', 'yellow') - {% if sample_groups[0].se_exists() %} - $('#samples_primary, #samples_other').DataTable( { - "columns": [ - { "bSortable": false }, - { "type": "natural" }, - { "type": "natural", "width": js_data.sample_column_width}, - { "type": "cust-txt" }, - { "bSortable": false }, - { "type": "cust-txt" }{% if has_num_cases %}, - { "type": "cust-txt" }{% endif %}{% if sample_groups[0].attributes|length > 0 %},{% endif %} - {% for attribute in sample_groups[0].attributes %} - { "type": "natural" }{% if loop.index < sample_groups[0].attributes|length %},{% endif %} - {% endfor %} - ], - "columnDefs": [ { - "targets": 0, - "orderable": false - } ], - "order": [[1, "asc" ]], - "sDom": "RZtr", - "iDisplayLength": -1, - "autoWidth": true, - "bLengthChange": true, - "deferRender": false, - "bSortClasses": false, - "scrollY": "600px", - "scrollCollapse": false, - "colResize": { - "tableWidthFixed": false + $('#samples_primary').DataTable( { + 'initComplete': function(settings, json) { + $('.edit_sample_value').change(function() { + edit_data_change; + }); + }, + 'createdRow': function ( row, data, index ) { + $(row).attr('id', "Primary_" + data.this_id) + $(row).addClass("value_se"); + if (data.outlier) { + $(row).addClass("outlier"); + } + $('td', row).eq(0).attr("align", "center"); + $('td', row).eq(0).attr("style", "padding: 2px 0px 0px 2px;"); + $('td', row).eq(1).addClass("column_name-Index") + $('td', row).eq(1).attr("align", "right"); + $('td', row).eq(1).attr("style", "padding: 2px 4px 0px 2px;"); + $('td', row).eq(2).addClass("column_name-Sample") + $('td', row).eq(3).addClass("column_name-Value") + $('td', row).eq(3).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% if sample_groups[0].se_exists() %} + $('td', row).eq(4).attr("align", "center"); + $('td', row).eq(4).attr("style", "padding-left: 2px; padding-right: 2px;"); + $('td', row).eq(5).addClass("column_name-SE") + $('td', row).eq(5).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% if has_num_cases %} + $('td', row).eq(6).addClass("column_name-num_cases") + $('td', row).eq(6).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% endif %} {% else %} {% if has_num_cases %} + $('td', row).eq(4).addClass("column_name-num_cases") + $('td', row).eq(4).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% endif %} {% endif %} + }, + 'data': js_data['sample_lists'][0], + 'columns': [ + { + 'data': null, + 'orderDataType': "dom-checkbox", + 'render': function(data, type, row, meta) { + return '<input type="checkbox" name="searchResult" style="min-height: 20px;" class="checkbox edit_sample_checkbox" value="" checked="checked">' + } }, - "paging": false + { + 'title': "ID", + 'type': "natural", + 'data': "this_id" + }, + { + 'title': "Sample", + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + return '<span class="edit_sample_sample_name">' + data.name + '</span>' + } + }, + { + 'title': "Value", + 'orderDataType': "dom-input", + 'data': null, + 'render': function(data, type, row, meta) { + if (data.value == null) { + return '<input type="text" data-value="x" data-qnorm="x" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_value" value="x" size=6 maxlength=6>' + } else { + return '<input type="text" data-value="' + data.value + '" data-qnorm="' + js_data['qnorm_values'][0][parseInt(data.this_id)] + '" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_value" value="' + data.value + '" size=6 maxlength=6>' + } + } + }{% if sample_groups[0].se_exists() %}, + { + 'bSortable': false, + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + return '±' + } + }, + { + 'title': "SE", + 'orderDataType': "dom-input", + 'data': null, + 'render': function(data, type, row, meta) { + if (data.variance == null) { + return '<input type="text" data-value="x" data-qnorm="x" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_se" value="x" size=6 maxlength=6>' + } else { + return '<input type="text" data-value="' + data.variance + '" data-qnorm="x" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_se" value="' + data.variance + '" size=6 maxlength=6>' + } + } + }{% endif %}{% if has_num_cases %}, + { + 'title': "N", + 'type': "natural", + 'data': null, + 'orderDataType': "cust-txt", + 'render': function(data, type, row, meta) { + return '<input type="text" data-value="' + data.num_cases + '" data-qnorm="' + js_data['qnorm_vals'][0][parseInt(data.this_id)] + '" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_num_cases" value="' + data.num_cases + '" size=4 maxlength=4>' + } + }{% endif %}{% if sample_groups[0].attributes|length > 0 %}{% for attribute in sample_groups[0].attributes|sort() %}, + { + 'title': "{{ sample_groups[0].attributes[attribute].name }}", + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + return data.extra_attributes['{{ sample_groups[0].attributes[attribute].name }}'] + } + }{% endfor %}{% endif %} + ], + 'order': [[1, "asc"]], + 'sDom': "Ztr", + 'autoWidth': true, + 'deferRender': true, + 'paging': false, + 'orderClasses': true, + 'scrollY': "600px", + 'scrollCollapse': false, + 'processing': true, + 'language': { + 'loadingRecords': ' ', + 'processing': 'Loading...' + } } ); - {% else %} - - $('#samples_primary, #samples_other').DataTable( { - "columns": [ - { "bSortable": false, "width": "8%" }, - { "type": "natural", "width": "15%" }, - { "type": "natural", "width": "25%" }, - { "type": "cust-txt", "width": "25%" }{% if has_num_cases %}, - { "type": "cust-txt" }{% endif %}{% if sample_groups[0].attributes|length > 0 %},{% endif %} - {% for attribute in sample_groups[0].attributes %} - { "type": "natural" }{% if loop.index < sample_groups[0].attributes|length %},{% endif %} - {% endfor %} - ], - "columnDefs": [ { - "targets": 0, - "orderable": false - } ], - "order": [[1, "asc" ]], - "sDom": "RZtr", - "iDisplayLength": -1, - "autoWidth": true, - "bLengthChange": true, - "deferRender": false, - "bSortClasses": false, - "scrollY": "600px", - "scrollCollapse": false, - "colResize": { - "tableWidthFixed": false + {% if sample_groups|length != 1 %} + $('#samples_other').DataTable( { + 'initComplete': function(settings, json) { + $('.edit_sample_value').change(function() { + edit_data_change; + }); + }, + 'createdRow': function ( row, data, index ) { + $(row).attr('id', "Other_" + data.this_id) + $(row).addClass("value_se"); + if (data.outlier) { + $(row).addClass("outlier"); + } + $('td', row).eq(0).attr("align", "center"); + $('td', row).eq(0).attr("style", "padding: 2px 0px 0px 2px;"); + $('td', row).eq(1).addClass("column_name-Index") + $('td', row).eq(1).attr("align", "right"); + $('td', row).eq(1).attr("style", "padding: 2px 4px 0px 2px;"); + $('td', row).eq(2).addClass("column_name-Sample") + $('td', row).eq(3).addClass("column_name-Value") + $('td', row).eq(3).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% if sample_groups[1].se_exists() %} + $('td', row).eq(4).attr("align", "center"); + $('td', row).eq(4).attr("style", "padding-left: 2px; padding-right: 2px;"); + $('td', row).eq(5).addClass("column_name-SE") + $('td', row).eq(5).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% if has_num_cases %} + $('td', row).eq(6).addClass("column_name-num_cases") + $('td', row).eq(6).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% endif %} {% else %} {% if has_num_cases %} + $('td', row).eq(4).addClass("column_name-num_cases") + $('td', row).eq(4).attr("style", "text-align: right; padding-top: 2px; padding-bottom: 0px;"); + {% endif %} {% endif %} + }, + 'data': js_data['sample_lists'][1], + 'columns': [ + { + 'data': null, + 'orderDataType': "dom-checkbox", + 'render': function(data, type, row, meta) { + return '<input type="checkbox" name="searchResult" style="min-height: 20px;" class="checkbox edit_sample_checkbox" value="" checked="checked">' + } + }, + { + 'title': "ID", + 'type': "natural", + 'data': "this_id" }, - "paging": false + { + 'title': "Sample", + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + return '<span class="edit_sample_sample_name">' + data.name + '</span>' + } + }, + { + 'title': "Value", + 'orderDataType': "dom-input", + 'data': null, + 'render': function(data, type, row, meta) { + if (data.value == null) { + return '<input type="text" data-value="x" data-qnorm="x" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_value" value="x" size=6 maxlength=6>' + } else { + return '<input type="text" data-value="' + data.value + '" data-qnorm="' + js_data['qnorm_values'][1][parseInt(data.this_id)] + '" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_value" value="' + data.value + '" size=6 maxlength=6>' + } + } + }{% if sample_groups[1].se_exists() %}, + { + 'bSortable': false, + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + return '±' + } + }, + { + 'title': "SE", + 'orderDataType': "dom-input", + 'data': null, + 'render': function(data, type, row, meta) { + if (data.variance == null) { + return '<input type="text" data-value="x" data-qnorm="x" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_se" value="x" size=6 maxlength=6>' + } else { + return '<input type="text" data-value="' + data.variance + '" data-qnorm="x" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_se" value="' + data.variance + '" size=6 maxlength=6>' + } + } + }{% endif %}{% if has_num_cases %}, + { + 'title': "N", + 'type': "natural", + 'data': null, + 'orderDataType': "cust-txt", + 'render': function(data, type, row, meta) { + return '<input type="text" data-value="' + data.num_cases + '" data-qnorm="' + js_data['qnorm_vals'][1][parseInt(data.this_id)] + '" name="value:' + data.name + '" style="text-align: right;" class="trait_value_input edit_sample_num_cases" value="' + data.num_cases + '" size=4 maxlength=4>' + } + }{% endif %}{% if sample_groups[1].attributes|length > 0 %}{% for attribute in sample_groups[1].attributes|sort() %}, + { + 'title': "{{ sample_groups[1].attributes[attribute].name }}", + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + return data.extra_attributes['{{ sample_groups[1].attributes[attribute].name }}'] + } + }{% endfor %}{% endif %} + ], + 'order': [[1, "asc"]], + 'sDom': "Ztr", + 'autoWidth': true, + 'deferRender': true, + 'paging': false, + 'orderClasses': true, + 'scrollY': "600px", + 'scrollCollapse': false, + 'processing': true, + 'language': { + 'loadingRecords': ' ', + 'processing': 'Loading...' + } } ); - {% endif %} + $('#samples_primary, #samples_other').find("tr.outlier").css('background-color', 'yellow') + var slider = document.getElementById('p_range_slider'); noUiSlider.create(slider, { start: [-1.0, 1.0], diff --git a/wqflask/wqflask/templates/show_trait_edit_data.html b/wqflask/wqflask/templates/show_trait_edit_data.html index 090602f4..a5e42fdb 100644 --- a/wqflask/wqflask/templates/show_trait_edit_data.html +++ b/wqflask/wqflask/templates/show_trait_edit_data.html @@ -1,176 +1,29 @@ <div> - <!--<h2>Review and Edit Data</h2>--> - -<!-- - <div class="well form-horizontal"> - <fieldset id="showHideOptions"> - <legend>Block samples</legend> - <p>Edit or delete values in the Trait Data boxes, and use the - <strong>Reset</strong> option as - needed. - </p> - - <div id="blockMenuSpan" class="input-append" style="margin-bottom: 10px;"> - <label for="remove_samples_field">Block samples by index:</label> - <input type="text" id="remove_samples_field"> - <select id="block_group" size="1"> - <option value="primary"> - {{ sample_group_types['samples_primary'] }} - </option> - <option value="other"> - {{ sample_group_types['samples_other'] }} - </option> - </select> - <input type="button" id="block_by_index" class="btn" value="Block"> - </div> - <div id="remove_samples_invalid" class="alert alert-error" style="display:none;"> - Please check that your input is formatted correctly, e.g. <strong>3, 5-10, 12</strong> - </div> - {% if sample_groups[0].attributes %} - <div class="input-append" style="margin-top:10px; margin-bottom:10px;"> - <label for="exclude_menu">Block samples by group:</label> - <select id="exclude_menu" size=1> - {% for attribute in sample_groups[0].attributes %} - <option value="{{ sample_groups[0].attributes[attribute].name.replace(' ', '_') }}"> - {{ sample_groups[0].attributes[attribute].name }}</option> - {% endfor %} - </select> - <select id="attribute_values" size=1> - </select> - <input type="button" id="exclude_group" class="btn" value="Block"> - </div> - {% endif %} - <div> - <input type="button" id="hide_no_value" class="btn btn-default" value="Hide No Value"> - <input type="button" id="block_outliers" class="btn btn-default" value="Block Outliers"> - <input type="button" id="reset" class="btn btn-primary" value="Reset"> - <span class="input-append"> - <input type="button" id="export" class="btn btn-default" value="Export"> - <select id="export_format" class="select optional span2"> - <option value="excel">Excel</option> - <option value="csv">CSV</option> - </select> - </span> - <br> - <div style="margin-top:10px;"> - <input type="button" id="normalize" class="btn btn-default" value="Normalize"> - <select id="norm_method" class="select optional span2"> - <option value="log2">Log2</option> - <option value="qnorm">Quantile</option> - <option value="sqrt">Square Root</option> - </select> - </div> - </div> - </fieldset> - <br> - - <div> - <p>Outliers highlighted in - <strong style="background-color:yellow;">yellow</strong> - can be hidden using - the <strong>Hide Outliers</strong> button. - </p> - - <p>Samples with no value (x) can be hidden by clicking - <strong>Hide No Value</strong> button. - </p> - </div> + <div style="padding-bottom: 10px;"> + <input type="button" class="btn btn-primary reset" value="Reset"> + <span class="input-append"> + <input type="button" class="btn btn-default export" value="Export"> + <select class="select optional span2 export_format"> + <option value="excel">Excel</option> + <option value="csv">CSV</option> + </select> + </span> </div> - <br> ---> - <!--<div id="edit_sample_lists">--> {% for sample_type in sample_groups %} {% set outer_loop = loop %} <div class="sample_group" style="width:{{ trait_table_width }};"> <h3>{{ sample_type.header }}</h3> - <hr> + <hr style="margin-top: 4px; margin-bottom: 10px; height: 1px; background-color: #A9A9A9;"> <div id="table_container"> <table class="table-hover table-striped cell-border" id="samples_{{ sample_type.sample_group_type }}" style="float: left; width:100%;"> - <thead> - <tr> - <th></th> - <th>ID</th> - <th>Sample</th> - <th style="text-align: right;">Value</th> - {% if sample_type.se_exists() %} - <th style="padding-left: 3px; padding-right: 3px;"> </th> - <th style="text-align: right;">SE</th> - {% endif %} - {% if has_num_cases %} - <th style="text-align: right;">N</th> - {% endif %} - {% for attribute in sample_type.attributes|sort() %} - <th> - {{ sample_type.attributes[attribute].name }} - </th> - {% endfor %} - </tr> - </thead> <tbody> - {% for sample in sample_type.sample_list %} - <tr class="{{ sample.class_outlier }} value_se" id="{% if outer_loop.index == 1 %}Primary_{{ sample.this_id }}{% else %}Other_{{ sample.this_id }}{% endif %}"> - <td align="center" style="padding-left: 0px; padding-right: 0px; padding-top: 2px; padding-bottom: 0px;" class="column_name-"><input type="checkbox" name="selectCheck" class="checkbox edit_sample_checkbox" style="min-height: 20px;" value="{{ sample.name }}" checked="checked"> - </td> - <td class="column_name-Index" align="right">{{ loop.index }}</td> - <td class="column_name-Sample"> - <span class="edit_sample_sample_name"> - {{ sample.name }} - </span> - </td> - - {# Todo: Add IDs #} - <td class="column_name-Value" align="right" style="padding-top: 2px; padding-bottom: 0px;"> - <input type="text" data-value="{{ sample.display_value }}" data-qnorm="{{ qnorm_vals[outer_loop.index - 1][loop.index - 1] }}" name="{{ 'value:' + sample.name }}" - style="text-align:right;" - class="trait_value_input edit_sample_value" - value="{{ sample.display_value }}" - size=6 maxlength=6 - > - </td> - - {% if sample_type.se_exists() %} - <td align="center" style="padding-left: 2px; padding-right: 2px;"> - ± - </td> - - {# Todo: Add IDs #} - <td class="column_name-SE" align="right" style="padding-top: 2px; padding-bottom: 0px;"> - <input type="text" data-value="{{ sample.display_variance }}" data-qnorm="x" name="{{ 'variance:' + sample.name}}" - style="text-align:right;" - class="trait_value_input edit_sample_se" - value="{{ sample.display_variance }}" - size=6 maxlength=6 - > - </td> - {% endif %} - {% if has_num_cases %} - <td class="column_name-num_cases" align="right"> - <input type="text" data-value="{{ sample.display_num_cases }}" name="{{ 'num_cases:' + sample.name}}" - style="text-align:right;" - class="trait_value_input edit_sample_num_cases" - value="{{ sample.display_num_cases }}" - size=4 maxlength=4 - > - </td> - {% endif %} - - {# Loop through each attribute type and input value #} - {% for attribute in sample_type.attributes|sort() %} - <td class="std_cell column_name-{{ sample_type.attributes[attribute].name.replace(' ', '_') }}"> - {{ sample.extra_attributes[sample_type.attributes[attribute].name] }} - </td> - {% endfor %} - </tr> - {% endfor %} + <td colspan="100%" align="center"><br><b><font size="15">Loading...</font></b><br></td> </tbody> </table> </div> </div> <br> {% endfor %} - <!--</div>--> - - <input type="hidden" name="Default_Name"> </div> diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index e0bc8eb8..e7f3eca3 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -242,7 +242,7 @@ <div class="mapping_method_fields form-group"> <label style="text-align:right;" for="mapping_permutations" class="col-xs-3 control-label">Permutations</label> <div style="margin-left:20px;" class="col-xs-4 controls"> - <input name="num_perm_rqtl_geno" value="2000" type="text" class="form-control"> + <input name="num_perm_rqtl_geno" value="0" type="text" class="form-control"> </div> </div> <div class="mapping_method_fields form-group"> @@ -268,9 +268,9 @@ <label style="text-align:right;" for="mapmethod_rqtl_geno" class="col-xs-3 control-label">Method</label> <div style="margin-left:20px;" class="col-xs-4 controls"> <select name="mapmethod_rqtl_geno" class="form-control"> + <option value="hk" selected>hk</option> <option value="em">em</option> <option value="imp">imp</option> - <option value="hk">hk</option> <option value="ehk">ehk</option> <option value="mr">mr</option> <option value="mr-imp">mr-imp</option> diff --git a/wqflask/wqflask/templates/show_trait_transform_and_filter.html b/wqflask/wqflask/templates/show_trait_transform_and_filter.html index fdf34c27..d1765778 100644 --- a/wqflask/wqflask/templates/show_trait_transform_and_filter.html +++ b/wqflask/wqflask/templates/show_trait_transform_and_filter.html @@ -39,10 +39,10 @@ <div> <input type="button" id="hide_no_value" class="btn btn-default" value="Hide No Value"> <input type="button" id="block_outliers" class="btn btn-default" value="Block Outliers"> - <input type="button" id="reset" class="btn btn-primary" value="Reset"> + <input type="button" class="btn btn-primary reset" value="Reset"> <span class="input-append"> - <input type="button" id="export" class="btn btn-default" value="Export"> - <select id="export_format" class="select optional span2"> + <input type="button" class="btn btn-default export" value="Export"> + <select class="select optional span2 export_format"> <option value="excel">Excel</option> <option value="csv">CSV</option> </select> |