From 823169d970d8b64e955f7316e6df87c5204b4864 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 1 Aug 2019 12:08:33 -0500 Subject: Made some more aesthetic changes to various pages and charts/figures Added some information to the mapping loading page --- wqflask/base/trait.py | 17 +++-- wqflask/wqflask/show_trait/show_trait.py | 83 ++++++++++++---------- .../new/javascript/plotly_probability_plot.js | 19 ++--- .../wqflask/static/new/javascript/show_trait.js | 73 +++++++++++-------- .../new/javascript/show_trait_mapping_tools.js | 2 +- wqflask/wqflask/templates/base.html | 2 +- wqflask/wqflask/templates/correlation_matrix.html | 2 +- wqflask/wqflask/templates/index_page_orig.html | 8 +-- wqflask/wqflask/templates/loading.html | 20 +++++- .../wqflask/templates/new_security/login_user.html | 83 ++++++++++------------ wqflask/wqflask/templates/search_result_page.html | 11 +-- wqflask/wqflask/views.py | 10 +++ 12 files changed, 194 insertions(+), 136 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 0527449b..39dd075e 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, division, print_function import string import resource import codecs +import requests import redis Redis = redis.StrictRedis() @@ -120,11 +121,17 @@ class GeneralTrait(object): @property def alias_fmt(self): '''Return a text formatted alias''' - if self.alias: - alias = string.replace(self.alias, ";", " ") - alias = string.join(string.split(alias), ", ") - else: - alias = 'Not available' + + alias = 'Not available' + if self.symbol: + response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol) + alias_list = json.loads(response.content) + alias = "; ".join(alias_list) + + if alias == 'Not available': + if self.alias: + alias = string.replace(self.alias, ";", " ") + alias = string.join(string.split(alias), ", ") return alias diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 1dd80962..f1f5840f 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -142,40 +142,6 @@ class ShowTrait(object): self.qnorm_vals = quantile_normalize_vals(self.sample_groups) self.z_scores = get_z_scores(self.sample_groups) - # Todo: Add back in the ones we actually need from below, as we discover we need them - hddn = OrderedDict() - - if self.dataset.group.allsamples: - hddn['allsamples'] = string.join(self.dataset.group.allsamples, ' ') - - hddn['trait_id'] = self.trait_id - hddn['dataset'] = self.dataset.name - hddn['temp_trait'] = False - if self.temp_trait: - hddn['temp_trait'] = True - hddn['group'] = self.temp_group - hddn['species'] = self.temp_species - hddn['use_outliers'] = False - hddn['method'] = "gemma" - hddn['selected_chr'] = -1 - hddn['mapping_display_all'] = True - hddn['suggestive'] = 0 - hddn['num_perm'] = 0 - hddn['manhattan_plot'] = "" - hddn['control_marker'] = "" - if not self.temp_trait: - if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish": - hddn['control_marker'] = self.nearest_marker - #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2 - hddn['do_control'] = False - hddn['maf'] = 0.05 - 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 - self.temp_uuid = uuid.uuid4() self.sample_group_types = OrderedDict() @@ -216,18 +182,61 @@ class ShowTrait(object): sample_column_width = max_samplename_width * 8 - if self.num_values >= 500: + if self.num_values >= 5000: self.maf = 0.01 else: self.maf = 0.05 trait_symbol = None + short_description = None if not self.temp_trait: if self.this_trait.symbol: trait_symbol = self.this_trait.symbol + short_description = trait_symbol + + elif self.this_trait.post_publication_abbreviation: + short_description = self.this_trait.post_publication_abbreviation + + elif self.this_trait.pre_publication_abbreviation: + short_description = self.this_trait.pre_publication_abbreviation + + # Todo: Add back in the ones we actually need from below, as we discover we need them + hddn = OrderedDict() + + if self.dataset.group.allsamples: + hddn['allsamples'] = string.join(self.dataset.group.allsamples, ' ') + hddn['primary_samples'] = string.join(self.primary_sample_names, ',') + hddn['trait_id'] = self.trait_id + hddn['dataset'] = self.dataset.name + hddn['temp_trait'] = False + if self.temp_trait: + hddn['temp_trait'] = True + hddn['group'] = self.temp_group + hddn['species'] = self.temp_species + hddn['use_outliers'] = False + hddn['method'] = "gemma" + hddn['selected_chr'] = -1 + hddn['mapping_display_all'] = True + hddn['suggestive'] = 0 + hddn['num_perm'] = 0 + hddn['manhattan_plot'] = "" + hddn['control_marker'] = "" + if not self.temp_trait: + if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish": + hddn['control_marker'] = self.nearest_marker + #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2 + hddn['do_control'] = False + hddn['maf'] = 0.05 + 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 js_data = dict(trait_id = self.trait_id, trait_symbol = trait_symbol, + short_description = short_description, unit_type = trait_units, dataset_type = self.dataset.type, data_scale = self.dataset.data_scale, @@ -396,6 +405,8 @@ class ShowTrait(object): sample_group_type='primary', header="%s Only" % (self.dataset.group.name)) self.sample_groups = (primary_samples,) + + self.primary_sample_names = primary_sample_names self.dataset.group.allsamples = all_samples_ordered def quantile_normalize_vals(sample_groups): @@ -493,7 +504,7 @@ def get_genofiles(this_dataset): return jsondata['genofile'] def get_table_widths(sample_groups, has_num_cases=False): - stats_table_width = 200 + stats_table_width = 250 if len(sample_groups) > 1: stats_table_width = 450 diff --git a/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js b/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js index a9c5676c..cc4195e4 100644 --- a/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js +++ b/wqflask/wqflask/static/new/javascript/plotly_probability_plot.js @@ -171,22 +171,23 @@ } var layout = { - title: js_data.trait_id, + title: "Trait " + js_data.trait_id + ": " + js_data.short_description + "", margin: { - l: 65, + l: 100, r: 30, t: 80, - b: 80 + b: 60 }, xaxis: { - title: "Normal Theoretical Quantiles", + title: "Normal Theoretical Quantiles", range: [first_x, last_x], zeroline: false, visible: true, linecolor: 'black', linewidth: 1, titlefont: { - size: 16 + family: "arial", + size: 20 }, ticklen: 4, tickfont: { @@ -194,19 +195,21 @@ } }, yaxis: { - title: "Data Quantiles", + title: "Data Quantiles", zeroline: false, visible: true, linecolor: 'black', linewidth: 1, titlefont: { - size: 16 + family: "arial", + size: 20 }, ticklen: 4, tickfont: { size: 16 }, - tickformat: tick_digits + tickformat: tick_digits, + automargin: true }, hovermode: "closest" } diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 8366ec0a..48b6da5e 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -30,11 +30,11 @@ Stat_Table_Rows = [ }, { vn: "min", pretty: "Minimum", - digits: 2 + digits: 3 }, { vn: "max", pretty: "Maximum", - digits: 2 + digits: 3 } ] @@ -67,7 +67,7 @@ Stat_Table_Rows.push( digits: 3 }, { vn: "interquartile", - pretty: "Interquartile Range", + pretty: "Interquartile Range", url: "http://www.genenetwork.org/glossary.html#Interquartile", digits: 3 }, { @@ -334,9 +334,9 @@ update_prob_plot = function() { make_table = function() { var header, key, row, row_line, table, the_id, the_rows, value, _i, _len, _ref, _ref1; if (js_data.trait_symbol != null) { - header = "Trait: " + js_data.trait_id + " - " + js_data.trait_symbol + "Statistic"; + header = "Trait " + js_data.trait_id + " - " + js_data.trait_symbol + "Statistic"; } else { - header = "Trait: " + js_data.trait_id + "Statistic"; + header = "Trait " + js_data.trait_id + "Statistic"; } _ref = js_data.sample_group_types; for (key in _ref) { @@ -990,12 +990,13 @@ var hist_trace = { root.histogram_data = [hist_trace]; root.histogram_layout = { bargap: 0.05, - title: js_data.trait_id, + title: "Trait " + js_data.trait_id + ": " + js_data.short_description + "", xaxis: { autorange: true, - title: "Value", + title: "Value", titlefont: { - size: 16 + family: "arial", + size: 20 }, ticklen: 4, tickfont: { @@ -1004,23 +1005,25 @@ root.histogram_layout = { }, yaxis: { autorange: true, - title: "Count", + title: "Count", titlefont: { - size: 16 + family: "arial", + size: 20 }, showline: true, ticklen: 4, tickfont: { size: 16 - } + }, + automargin: true }, width: 500, height: 600, margin: { - l: 50, + l: 70, r: 30, t: 100, - b: 60 + b: 50 } }; @@ -1036,25 +1039,34 @@ $('.histogram_samples_group').change(function() { }); root.box_layout = { - title: js_data.trait_id, xaxis: { showline: true, + titlefont: { + family: "arial", + size: 20 + }, tickfont: { size: 16 }, }, yaxis: { - title: js_data.unit_type, + title: "" + js_data.unit_type +"", autorange: true, showline: true, + titlefont: { + family: "arial", + size: 20 + }, ticklen: 4, tickfont: { size: 16 }, - tickformat: tick_digits + tickformat: tick_digits, + zeroline: false, + automargin: true }, margin: { - l: 50, + l: 90, r: 30, t: 30, b: 80 @@ -1122,7 +1134,7 @@ if (full_sample_lists.length > 1) { { type: 'box', y: get_sample_vals(full_sample_lists[0]), - name: sample_group_list[0], + name: "Trait " + js_data.trait_id + "", boxpoints: 'Outliers', jitter: 0.5, whiskerwidth: 0.2, @@ -1150,28 +1162,36 @@ $('.box_plot_tab').click(function() { // Violin Plot root.violin_layout = { - title: js_data.trait_id, xaxis: { showline: true, + titlefont: { + family: "arial", + size: 20 + }, tickfont: { size: 16 } }, yaxis: { - title: js_data.unit_type, + title: ""+js_data.unit_type+"", autorange: true, showline: true, + titlefont: { + family: "arial", + size: 20 + }, ticklen: 4, tickfont: { size: 16 }, tickformat: tick_digits, - zeroline: false + zeroline: false, + automargin: true }, margin: { - l: 50, + l: 90, r: 30, - t: 80, + t: 30, b: 80 } }; @@ -1239,14 +1259,11 @@ if (full_sample_lists.length > 1) { box: { visible: true }, - line: { - color: 'green', - }, meanline: { visible: true }, - name: sample_group_list[0], - x0: sample_group_list[0] + name: "Trait " + js_data.trait_id + "", + x0: "Trait " + js_data.trait_id + "" } ] } diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js index 8001dfc9..8db9522c 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -156,7 +156,7 @@ 'score_type', 'suggestive', 'significant', 'num_perm', 'permCheck', 'perm_output', 'num_bootstrap', 'bootCheck', 'bootstrap_results', 'LRSCheck', 'covariates', 'maf', 'use_loco', 'manhattan_plot', 'control_marker', 'control_marker_db', 'do_control', 'genofile', 'pair_scan', 'startMb', 'endMb', 'graphWidth', 'lrsMax', 'additiveCheck', 'showSNP', 'showGenes', 'viewLegend', 'haplotypeAnalystCheck', - 'mapmethod_rqtl_geno', 'mapmodel_rqtl_geno', 'temp_trait', 'group', 'species', 'reaper_version'] + 'mapmethod_rqtl_geno', 'mapmodel_rqtl_geno', 'temp_trait', 'group', 'species', 'reaper_version', 'primary_samples'] $("#rqtl_geno_compute").on("click", (function(_this) { return function() { diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 80bbd7f5..2366bdec 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -94,7 +94,7 @@
- diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html index 7e67ece2..34a15c6a 100644 --- a/wqflask/wqflask/templates/correlation_matrix.html +++ b/wqflask/wqflask/templates/correlation_matrix.html @@ -10,7 +10,7 @@

Correlation Matrix

-
Lower left cells list Pearson product-moment correlations; upper right cells list Spearman rank order correlations. Each cell also contains the n of cases. Values ranging from 0.4 to 1.0 range from dark blue to white, while values ranging from -0.4 to -1.0 range from orange to white. Select any cell to generate a scatter plot. Select trait labels for more information.
+
Lower left cells list Pearson product-moment correlations; upper right cells list Spearman rank order correlations. Each cell also contains the n of cases. Values ranging from 0.4 to 1.0 range from orange to white, while values ranging from -0.4 to -1.0 range from dark blue to white. Select any cell to generate a scatter plot. Select trait labels for more information.

{% if lowest_overlap < 8 %}
Caution: This matrix of correlations contains some cells with small sample sizes of fewer than 8.
diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html index 286f6c1f..ed91a886 100755 --- a/wqflask/wqflask/templates/index_page_orig.html +++ b/wqflask/wqflask/templates/index_page_orig.html @@ -28,7 +28,7 @@ - +
@@ -241,7 +241,7 @@

GeneNetwork v2:

GeneNetwork v1:

    diff --git a/wqflask/wqflask/templates/loading.html b/wqflask/wqflask/templates/loading.html index 25560249..3eb061e5 100644 --- a/wqflask/wqflask/templates/loading.html +++ b/wqflask/wqflask/templates/loading.html @@ -7,10 +7,24 @@
    -
    +
    + {% if start_vars.tool_used == "Mapping" %} +

    Computing the Map

    +
    + n = {{ start_vars.num_vals }} +
    + Method = {{ start_vars.method }} +
    + {% if start_vars.transform != "" %} + transform = {{ start_vars.transform }} +
    + {% endif %} + MAF = {{ start_vars.maf }} + {% else %}

    Loading {{ start_vars.tool_used }} Results...

    + {% endif %}
    -
    +
    @@ -22,5 +36,5 @@ \ No newline at end of file diff --git a/wqflask/wqflask/templates/new_security/login_user.html b/wqflask/wqflask/templates/new_security/login_user.html index 27b20ebf..c9aaf028 100644 --- a/wqflask/wqflask/templates/new_security/login_user.html +++ b/wqflask/wqflask/templates/new_security/login_user.html @@ -2,53 +2,11 @@ {% block title %}Register{% endblock %} {% block content %} -
    +
    {{ flash_me() }} - - - -
    - -

    Don't have an account?

    - - {% if es_server: %} - Create a new account - {% else: %} -
    -

    You cannot create an account at this moment.
    - Please try again later.

    -
    - {% endif %} - -
    -

    Login with external services

    - - {% if external_login: %} -
    - {% if external_login["github"]: %} - Login with Github - {% else %} -

    Github login is not available right now

    - {% endif %} - - {% if external_login["orcid"]: %} - Login with ORCID - {% else %} -

    ORCID login is not available right now

    - {% endif %} -
    - {% else: %} -
    -

    Sorry, you cannot login with Github or ORCID at this time.

    -
    - {% endif %} -
    - -

    Already have an account? Sign in here.

    +

    Already have an account? Sign in here.

    {% if es_server: %} @@ -69,7 +27,6 @@
    -
    @@ -87,6 +44,42 @@
+
+ +

Don't have an account?

+ + {% if es_server: %} + Create a new account + {% else: %} +
+

You cannot create an account at this moment.
+ Please try again later.

+
+ {% endif %} + +
+

Login with external services

+ + {% if external_login: %} +
+ {% if external_login["github"]: %} + Login with Github + {% else %} +

Github login is not available right now

+ {% endif %} + + {% if external_login["orcid"]: %} + Login with ORCID + {% else %} +

ORCID login is not available right now

+ {% endif %} +
+ {% else: %} +
+

Sorry, you cannot login with Github or ORCID at this time.

+
+ {% endif %} + {% else: %}
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index f5978196..2dded69f 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -13,7 +13,7 @@
-

We searched {{ dataset.fullname }} +

Search Results: We searched {{ dataset.fullname }} to find all records {% for word in search_terms %} {% if word.key|lower == "rif" %} @@ -249,6 +249,7 @@ 'columns': [ { 'data': null, + 'width': "30px", 'orderDataType': "dom-checkbox", 'orderSequence': [ "desc", "asc"], 'render': function(data, type, row, meta) { @@ -258,12 +259,14 @@ { 'title': "Index", 'type': "natural", + 'width': "30px", 'data': "index" }, { 'title': "Record", 'type': "natural", 'data': null, + 'width': "60px", 'orderDataType': "dom-inner-text", 'render': function(data, type, row, meta) { return '' + data.name + '' @@ -277,7 +280,6 @@ { 'title': "Description", 'type': "natural", - 'width': "300px", 'data': null, 'render': function(data, type, row, meta) { try { @@ -290,12 +292,13 @@ { 'title': "Location", 'type': "natural", - 'width': "140px", + 'width': "120px", 'data': "location" }, { 'title': "Mean", 'type': "natural", + 'width': "40px", 'data': "mean", 'orderSequence': [ "desc", "asc"] }, @@ -308,7 +311,7 @@ { 'title': "Max LRS Location", 'type': "natural", - 'width': "140px", + 'width': "120px", 'data': "lrs_location" }, { diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index fe858d52..7b585b03 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -560,6 +560,7 @@ def loading_page(): logger.info(request.url) initial_start_vars = request.form start_vars_container = {} + num_vals = 0 #ZS: So it can be displayed on loading page if 'wanted_inputs' in initial_start_vars: wanted = initial_start_vars['wanted_inputs'].split(",") start_vars = {} @@ -567,6 +568,15 @@ def loading_page(): if key in wanted or key.startswith(('value:')): start_vars[key] = value + if 'primary_samples' in start_vars: + samples = start_vars['primary_samples'].split(",") + for sample in samples: + value = start_vars.get('value:' + sample) + if value != "x": + num_vals += 1 + + start_vars['num_vals'] = num_vals + start_vars_container['start_vars'] = start_vars else: start_vars_container['start_vars'] = initial_start_vars -- cgit v1.2.3