diff options
author | zsloan | 2019-03-04 12:37:59 -0600 |
---|---|---|
committer | zsloan | 2019-03-04 12:37:59 -0600 |
commit | 3448aa90ffae2d714817216f3cca39decad75f63 (patch) | |
tree | b77c9eafdcc1047a81d20c32716ba2f48ead7a9b /wqflask | |
parent | fe94046b9fbd5b5d1f85920fc4263eb5c4aa1328 (diff) | |
download | genenetwork2-3448aa90ffae2d714817216f3cca39decad75f63.tar.gz |
Fixed excel export to show all columns
Fixed stats table to calculate Range and Interquartile Range correctly, and only show Range (fold) for appropriate traits
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/show_trait/export_trait_data.py | 16 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/show_trait.js | 43 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/stats.js | 31 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 6 |
4 files changed, 74 insertions, 22 deletions
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py index 558372bb..a99e72a6 100644 --- a/wqflask/wqflask/show_trait/export_trait_data.py +++ b/wqflask/wqflask/show_trait/export_trait_data.py @@ -27,11 +27,19 @@ def cmp_samples(a, b): if b[0] == 'name': return 1 elif b[0] == 'value': - if a[0] == 'se': + if a[0] == 'name': + return -1 + else: return 1 + elif b[0] == 'se': + if a[0] == 'name' or a[0] == 'value': + return -1 else: + return 1 + elif b[0] == 'num_cases': + if a[0] == 'name' or a[0] == 'value' or a[0] == 'se': return -1 - elif b[0] == 'se': - return -1 + else: + return 1 else: - return 0
\ No newline at end of file + return -1
\ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 9bbcd560..f49ef063 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -35,11 +35,33 @@ Stat_Table_Rows = [ vn: "max", pretty: "Maximum", digits: 2 - }, { - vn: "range", - pretty: "Range (log2)", - digits: 3 - }, { + } +] + +if (js_data.dataset_type == "ProbeSet"){ + if (js_data.data_scale == "linear_positive" || js_data.data_scale == "log2") { + Stat_Table_Rows.push({ + vn: "range", + pretty: "Range (log2)", + digits: 3 + }) + } else { + Stat_Table_Rows.push({ + vn: "range", + pretty: "Range", + digits: 3 + }) + } +} else { + Stat_Table_Rows.push({ + vn: "range", + pretty: "Range", + digits: 3 + }) +} + +Stat_Table_Rows.push( + { vn: "range_fold", pretty: "Range (fold)", digits: 3 @@ -57,7 +79,7 @@ Stat_Table_Rows = [ 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() { @@ -314,7 +336,7 @@ make_table = function() { 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"){ + if ((row.vn == "range_fold") && js_data.dataset_type == "Publish"){ continue; } row_line = "<tr>"; @@ -696,10 +718,13 @@ get_sample_table_data = function(table_name) { 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.value = $(element).find('.edit_sample_value:eq(0)').val(); + if ($(element).find('.edit_sample_se').length > 0) { row_data.se = $(element).find('.edit_sample_se').val(); } + if ($(element).find('.edit_sample_num_cases').length > 0) { + row_data.num_cases = $(element).find('.edit_sample_num_cases').val(); + } _ref = js_data.attribute_names; for (key in _ref) { if (!__hasProp.call(_ref, key)) continue; diff --git a/wqflask/wqflask/static/new/javascript/stats.js b/wqflask/wqflask/static/new/javascript/stats.js index 356d1cb0..4df03412 100644 --- a/wqflask/wqflask/static/new/javascript/stats.js +++ b/wqflask/wqflask/static/new/javascript/stats.js @@ -69,11 +69,23 @@ Stats = (function() { }; Stats.prototype.range = function() { - return this.max() - this.min(); + if (js_data.dataset_type == "ProbeSet"){ + if (js_data.data_scale == "linear_positive"){ + return Math.log2(this.max()) - Math.log2(this.min()); + } else { + return this.max() - this.min() + } + } else { + return this.max() - this.min() + } }; Stats.prototype.range_fold = function() { - return Math.pow(2, this.range()); + if (js_data.dataset_type == "ProbeSet"){ + return Math.pow(2, this.range()); + } else { + return this.range() + } }; Stats.prototype.interquartile = function() { @@ -81,10 +93,19 @@ Stats = (function() { 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)]; + if (js_data.dataset_type == "ProbeSet" && js_data.data_scale == "linear_positive") { + q1 = Math.log2(this.the_values[Math.floor(length * .25)]); + q3 = Math.log2(this.the_values[Math.floor(length * .75)]); + } else { + 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 (js_data.dataset_type == "ProbeSet") { + return Math.pow(2, iq); + } else { + return iq; + } }; Stats.prototype.skewness = function() { diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 67e83366..d00f067e 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -321,10 +321,8 @@ def export_trait_excel(): workbook = xlsxwriter.Workbook(buff, {'in_memory': True}) worksheet = workbook.add_worksheet() for i, row in enumerate(sample_data): - worksheet.write(i, 0, row[0]) - worksheet.write(i, 1, row[1]) - if len(row) > 2: - worksheet.write(i, 2, row[2]) + for j, column in enumerate(row): + worksheet.write(i, j, row[j]) workbook.close() excel_data = buff.getvalue() buff.close() |