From b964a8b732c1066978ce88073c009803f36a9173 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 6 Jul 2018 16:27:46 +0000 Subject: Added square root transform options Figures now correctly rescale when transforms are applied Fixed height of probability plot Removed some text related to pylmm since it's currently not being used --- .../static/new/javascript/draw_probability_plot.js | 2 +- .../new/javascript/plotly_probability_plot.js | 2 +- .../wqflask/static/new/javascript/show_trait.js | 25 +++++++++++++++++++++- .../wqflask/templates/show_trait_edit_data.html | 1 + .../templates/show_trait_mapping_tools.html | 4 ++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/wqflask/wqflask/static/new/javascript/draw_probability_plot.js b/wqflask/wqflask/static/new/javascript/draw_probability_plot.js index f23dad0c..3d756303 100644 --- a/wqflask/wqflask/static/new/javascript/draw_probability_plot.js +++ b/wqflask/wqflask/static/new/javascript/draw_probability_plot.js @@ -26,7 +26,7 @@ redraw_prob_plot = function(samples, sample_group) { var container, h, margin, totalh, totalw, w; h = 600; - w = 600; + w = 500; margin = { left: 60, top: 40, diff --git a/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js b/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js index 49fd53b1..185de8a9 100644 --- a/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js +++ b/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js @@ -25,7 +25,7 @@ redraw_prob_plot = function(samples, sample_group) { var container, h, margin, totalh, totalw, w; - h = 600; + h = 370; w = 600; margin = { left: 60, diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 5e2ecc33..d641dc67 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -247,6 +247,9 @@ } root.bar_data[0]['x'] = trait_samples Plotly.newPlot('bar_chart', root.bar_data, root.bar_layout); + Plotly.relayout('bar_chart', { + 'yaxis.autorange': true + }); }; redraw_box_plot = function() { @@ -564,7 +567,7 @@ log_normalize_data = function() { return $('.trait_value_input').each((function(_this) { return function(_index, element) { - current_value = $(element).data("value"); + current_value = parseFloat($(element).data("value")) + 1; if(isNaN(current_value)) { return current_value } else { @@ -575,6 +578,20 @@ })(this)); }; + sqrt_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.sqrt(current_value).toFixed(3)); + return Math.sqrt(current_value).toFixed(3) + } + }; + })(this)); + }; + qnorm_data = function() { return $('.trait_value_input').each((function(_this) { return function(_index, element) { @@ -596,6 +613,12 @@ $('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() diff --git a/wqflask/wqflask/templates/show_trait_edit_data.html b/wqflask/wqflask/templates/show_trait_edit_data.html index 482d1d88..ac2f1078 100644 --- a/wqflask/wqflask/templates/show_trait_edit_data.html +++ b/wqflask/wqflask/templates/show_trait_edit_data.html @@ -56,6 +56,7 @@ {% endif %} {% for mapping_method in dataset.group.mapping_names %} {% if mapping_method == "GEMMA" %} @@ -330,8 +332,10 @@