From 805b781e6eabfb42cbecb319fffc8ade855de914 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 16 Sep 2024 18:49:34 +0000 Subject: Handle Effect Size plots on the scatterplot page Added a new parameter to the scatterplot page ('effect') that causes the figures to be drawn differently. For example: - The plot width is different - Spearman Rank plot isn't displayed/generated - The number of X-axis ticks is explicitly set to 3, with no decimal places --- gn2/wqflask/correlation/corr_scatter_plot.py | 3 + .../static/new/javascript/draw_corr_scatterplot.js | 19 ++- gn2/wqflask/templates/corr_scatterplot.html | 177 +++++++++++---------- gn2/wqflask/templates/mapping_results.html | 2 +- 4 files changed, 106 insertions(+), 95 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/correlation/corr_scatter_plot.py b/gn2/wqflask/correlation/corr_scatter_plot.py index ab130cc5..79905cc2 100644 --- a/gn2/wqflask/correlation/corr_scatter_plot.py +++ b/gn2/wqflask/correlation/corr_scatter_plot.py @@ -45,6 +45,8 @@ class CorrScatterPlot: if self.dataset_1.group.f1list != None: primary_samples += self.dataset_1.group.f1list + self.effect_plot = True if 'effect' in params else False + if 'dataid' in params: trait_data_dict = json.loads(Redis.get(params['dataid'])) trait_data = {key:webqtlCaseData.webqtlCaseData(key, float(trait_data_dict[key])) for (key, value) in trait_data_dict.items() if trait_data_dict[key] != "x"} @@ -116,6 +118,7 @@ class CorrScatterPlot: self.js_data = dict( data=self.data, + effect_plot=self.effect_plot, rdata=self.rdata, indIDs=self.indIDs, trait_1=self.trait_1.dataset.name + ": " + str(self.trait_1.name), diff --git a/gn2/wqflask/static/new/javascript/draw_corr_scatterplot.js b/gn2/wqflask/static/new/javascript/draw_corr_scatterplot.js index f883c0d9..9a6d317d 100644 --- a/gn2/wqflask/static/new/javascript/draw_corr_scatterplot.js +++ b/gn2/wqflask/static/new/javascript/draw_corr_scatterplot.js @@ -24,8 +24,6 @@ if (y_val_range >= 2 && y_val_range < 8){ y_tick_digits = 'f' } -console.log("y_digits:", y_tick_digits) - var layout = { height: 700, width: 800, @@ -140,12 +138,8 @@ var modebar_options = { cofactor1_dict = {} ranked_cofactor1_dict = {} -//cofactor1_values = [] -//ranked_cofactor1_values = [] cofactor2_dict = {} ranked_cofactor2_dict = {} -//cofactor2_values = [] -//ranked_cofactor2_values = [] cofactor3_dict = {} ranked_cofactor3_dict = {} @@ -176,6 +170,15 @@ function drawg() { } } + // Change some plot settings if the plot is an Effect Size plot + if (js_data.effect_plot) { + layout['width'] = 500 + layout['xaxis']['nticks'] = 3 + layout['xaxis']['tickformat'] = '.0f' + layout['yaxis']['nticks'] = 3 + layout['yaxis']['tickformat'] = '.0f' + } + Plotly.newPlot('scatterplot2', [trace2, trace1], layout, modebar_options) } @@ -760,7 +763,9 @@ function chartupdatedata() { } drawg(); -srdrawg(); +if (!js_data.effect_plot) { + srdrawg(); +} $(".chartupdatewh").change(function () { chartupdatewh(); diff --git a/gn2/wqflask/templates/corr_scatterplot.html b/gn2/wqflask/templates/corr_scatterplot.html index c2586bc0..9532726c 100644 --- a/gn2/wqflask/templates/corr_scatterplot.html +++ b/gn2/wqflask/templates/corr_scatterplot.html @@ -126,18 +126,20 @@
  • Pearson
  • + {% if effect_plot == false %}
  • Spearman Rank
  • + {% endif %} -
    +


    -
    +
    {% if trait_1.dataset.type == "ProbeSet" %}
    @@ -248,101 +250,102 @@
    + {% if effect_plot == false %}


    -
    -
    - {% if trait_1.dataset.type == "ProbeSet" %} - -
    - [{{trait_1.symbol}} on {{trait_1.location_repr}} Mb] - {{trait_1.description_display}} -
    - {% elif trait_1.dataset.type == "Publish" %} - -
    - PubMed: {{trait_1.pubmed_text}} +
    +
    + {% if trait_1.dataset.type == "ProbeSet" %} + +
    + [{{trait_1.symbol}} on {{trait_1.location_repr}} Mb] {{trait_1.description_display}} -
    - {% endif %} +
    + {% elif trait_1.dataset.type == "Publish" %} + +
    + PubMed: {{trait_1.pubmed_text}} + {{trait_1.description_display}} +
    + {% endif %} -
    +
    - {% if trait_2.dataset.type == "ProbeSet" %} - -
    - [{{trait_2.symbol}} on {{trait_2.location_repr}} Mb] - {{trait_2.description_display}} -
    - {% elif trait_2.dataset.type == "Publish" %} - -
    - PubMed: {{trait_2.pubmed_text}} + {% if trait_2.dataset.type == "ProbeSet" %} + +
    + [{{trait_2.symbol}} on {{trait_2.location_repr}} Mb] {{trait_2.description_display}} +
    + {% elif trait_2.dataset.type == "Publish" %} + +
    + PubMed: {{trait_2.pubmed_text}} + {{trait_2.description_display}} +
    + {% endif %} +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    StatisticValue
    Number{{jsdata.num_overlap}}
    Slope{{ jsdata.srslope_string }}
    Intercept{{'%0.3f' % jsdata.srintercept}}
    r value{{'%0.3f' % jsdata.srr_value}}
    P value{% if jsdata.srp_value < 0.001 %}{{'%0.3e' % jsdata.srp_value}}{% else %}{{'%0.3f' % jsdata.srp_value}}{% endif %}
    + Regression Line +
    + y = {{ jsdata.srslope_string }} * x {% if jsdata.srintercept < 0 %}- {{'%0.3f' % (jsdata.srintercept * -1)}}{% else %}+ {{'%0.3f' % jsdata.srintercept}}{% endif %} +
    - {% endif %} -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    StatisticValue
    Number{{jsdata.num_overlap}}
    Slope{{ jsdata.srslope_string }}
    Intercept{{'%0.3f' % jsdata.srintercept}}
    r value{{'%0.3f' % jsdata.srr_value}}
    P value{% if jsdata.srp_value < 0.001 %}{{'%0.3e' % jsdata.srp_value}}{% else %}{{'%0.3f' % jsdata.srp_value}}{% endif %}
    - Regression Line -
    - y = {{ jsdata.srslope_string }} * x {% if jsdata.srintercept < 0 %}- {{'%0.3f' % (jsdata.srintercept * -1)}}{% else %}+ {{'%0.3f' % jsdata.srintercept}}{% endif %} -
    -
    -
    - +
    + {% endif %}
    {% endblock %} diff --git a/gn2/wqflask/templates/mapping_results.html b/gn2/wqflask/templates/mapping_results.html index 2b1660fd..c27de85e 100644 --- a/gn2/wqflask/templates/mapping_results.html +++ b/gn2/wqflask/templates/mapping_results.html @@ -416,7 +416,7 @@ 'data': null, 'render': function(data, type, row, meta) { {% if geno_db_exists == "True" %} - return '' + String(parseFloat(data.additive).toFixed(3)) + '' + return '' + String(parseFloat(data.additive).toFixed(3)) + '' {% else %} return String(parseFloat(data.additive).toFixed(3)) {% endif %} -- cgit v1.2.3