From 7932f962aff0ac35dd53b84e483f405de81c0612 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 5 Nov 2020 15:07:58 -0600 Subject: Imported Scroller and used it with correlation page table --- wqflask/wqflask/templates/correlation_page.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index bc0b592c..06499ec6 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -215,6 +215,7 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> + <script type="text/javascript" src="https://cdn.datatables.net/scroller/2.0.2/js/dataTables.scroller.min.js"></script> <script type="text/javascript" charset="utf-8"> var table_json = {{ json_results | safe }} @@ -387,8 +388,9 @@ "autoWidth": false, "deferRender": true, "bSortClasses": false, - "paging": false, - "orderClasses": true + "scrollY": "50vh", + "scroller": true, + "scrollCollapse": true } {% elif target_dataset.type == "Publish" %} @@ -438,8 +440,9 @@ "autoWidth": false, "deferRender": true, "bSortClasses": false, - "paging": false, - "orderClasses": true, + "scrollY": "50vh", + "scroller": true, + "scrollCollapse": true } {% elif target_dataset.type == "Geno" %} table_conf = { @@ -474,7 +477,10 @@ "autoWidth": false, "bDeferRender": true, "scrollY": "800px", - "scrollCollapse": false + "scrollCollapse": false, + "scrollY": "50vh", + "scroller": true, + "scrollCollapse": true } {% endif %} -- cgit v1.2.3 From 8f70b408c6df130ba9bef2b159c32ef0c8d6c327 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 5 Nov 2020 15:21:28 -0600 Subject: Removed html from generate_corr_json since that will be done by the column definitions after passing the data to DataTables as JSON --- wqflask/wqflask/correlation/show_corr_results.py | 32 ++++++++---------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 4c2b64ba..f0187ef9 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -484,30 +484,26 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap if trait.view == False: continue results_dict = {} - if not for_api: - results_dict['checkbox'] = "<INPUT TYPE='checkbox' NAME='searchResult' class='checkbox trait_checkbox' style='padding-right: 0px;' VALUE='" + hmac.hmac_creation('{}:{}'.format(trait.name, trait.dataset.name)) + "'>" - results_dict['index'] = i + 1 - results_dict['trait_id'] = "<a href='/show_trait?trait_id="+str(trait.name)+"&dataset="+str(dataset.name)+"'>"+str(trait.name)+"</a>" - else: - results_dict['trait_id'] = trait.name + results_dict['index'] = i + 1 + results_dict['trait_id'] = trait.name if target_dataset.type == "ProbeSet": results_dict['symbol'] = trait.symbol results_dict['description'] = trait.description_display results_dict['location'] = trait.location_repr - results_dict['mean'] = float(trait.mean) + if trait.mean and trait.mean != "": + results_dict['mean'] = float(trait.mean) + else: + results_dict['mean'] = "N/A" if trait.LRS_score_repr != "N/A": results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) else: results_dict['lrs_score'] = "N/A" results_dict['lrs_location'] = trait.LRS_location_repr - if trait.additive != "": + if trait.additive and trait.additive != "": results_dict['additive'] = "%0.3f" % float(trait.additive) else: results_dict['additive'] = "N/A" - if for_api: - results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) - else: - results_dict['sample_r'] = "<a target='_blank' href='corr_scatter_plot?dataset_1=" + str(dataset.name) + "&dataset_2=" + str(trait.dataset.name) + "&trait_1=" + str(this_trait.name) + "&trait_2=" + str(trait.name) + "'>" + "%0.3f" % float(trait.sample_r) + "</a>" + results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) if trait.lit_corr == "" or trait.lit_corr == 0: @@ -535,22 +531,16 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['pubmed'] = "N/A" results_dict['lrs_score'] = trait.LRS_score_repr results_dict['lrs_location'] = trait.LRS_location_repr - if trait.additive != "": + if trait.additive and trait.additive != "": results_dict['additive'] = "%0.3f" % float(trait.additive) else: results_dict['additive'] = "N/A" - if for_api: - results_dict['sample_r'] = "%0.3f" % trait.sample_r - else: - results_dict['sample_r'] = "<a target='_blank' href='corr_scatter_plot?dataset_1=" + str(dataset.name) + "&dataset_2=" + str(trait.dataset.name) + "&trait_1=" + str(this_trait.name) + "&trait_2=" + str(trait.name) + "'>" + "%0.3f" % trait.sample_r + "</a>" + results_dict['sample_r'] = "%0.3f" % trait.sample_r results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) else: results_dict['lrs_location'] = trait.LRS_location_repr - if for_api: - results_dict['sample_r'] = "%0.3f" % trait.sample_r - else: - results_dict['sample_r'] = "<a target='_blank' href='corr_scatter_plot?dataset_1=" + str(dataset.name) + "&dataset_2=" + str(trait.dataset.name) + "&trait_1=" + str(this_trait.name) + "&trait_2=" + str(trait.name) + "'>" + "%0.3f" % float(trait.sample_r) + "</a>" + results_dict['sample_r'] = "%0.3f" % trait.sample_r results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) -- cgit v1.2.3 From 0afe0620216635eeda6e7481e7bc917e0976042b Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 5 Nov 2020 17:07:57 -0600 Subject: Added some additional necessary fields to generate_corr_json in show_corr_results.py --- wqflask/wqflask/correlation/show_corr_results.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index f0187ef9..ebfea8fe 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -486,8 +486,13 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict = {} results_dict['index'] = i + 1 results_dict['trait_id'] = trait.name + results_dict['dataset'] = trait.dataset.name if target_dataset.type == "ProbeSet": results_dict['symbol'] = trait.symbol + if len(trait.description_display) > 40: + results_dict['description'] = trait.description_display[:40] + "..." + else: + results_dict['description'] = trait.description_display results_dict['description'] = trait.description_display results_dict['location'] = trait.location_repr if trait.mean and trait.mean != "": @@ -512,11 +517,26 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr) if trait.tissue_corr == "" or trait.tissue_corr == 0: results_dict['tissue_corr'] = "--" + results_dict['tissue_pvalue'] = "--" else: results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) + results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) elif target_dataset.type == "Publish": - results_dict['description'] = trait.description_display + results_dict['abbreviation'] = trait.abbreviation + if len(trait.abbreviation) > 20: + results_dict['abbreviation_display'] = trait.abbreviation[:20] + "..." + else: + results_dict['abbreviation_display'] = trait.abbreviation + if len(trait.description_display) > 40: + results_dict['description'] = trait.description_display[:40] + "..." + else: + results_dict['description'] = trait.description_display results_dict['authors'] = trait.authors + authors_list = trait.authors.split(',') + if len(authors_list > 6): + results_dict['authors_display'] = authors_list[:6].join(", ") + ", et al." + else: + results_dict['authors_display'] = trait.authors if trait.pubmed_id: if for_api: results_dict['pubmed_id'] = trait.pubmed_id -- cgit v1.2.3 From 57ec6e53180375a2106c3b81b764103d9dcc6bf5 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 5 Nov 2020 17:09:32 -0600 Subject: Converted correlation table for ProbeSet target datasets to use the JSON input and removed the unused table html --- wqflask/wqflask/templates/correlation_page.html | 360 +++++++++++++++++------- 1 file changed, 251 insertions(+), 109 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 06499ec6..6f92fcb5 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -2,9 +2,9 @@ {% block title %}Correlation Results{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> - <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> + <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} {% block content %} <div class="container" style="min-width: 1250px;"> @@ -127,77 +127,7 @@ </thead> <tbody> - {% for trait in correlation_results %} - <tr> - <td><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td> - <td data-export="{{ loop.index }}" style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: right;">{{ loop.index }}</td> - <td data-export="{{ trait.name }}"> - <a href="{{ url_for('show_trait_page', - trait_id = trait.name, - dataset = trait.dataset.name - )}}"> - {{ trait.name }} - </a> - </td> - {% if target_dataset.type == 'ProbeSet' %} - <td data-export="{{ trait.symbol }}">{{ trait.symbol }}</td> - <td data-export="{{ trait.description_display }}">{{ trait.description_display }}</TD> - <td data-export="{{ trait.location_repr }}" style="white-space: nowrap;">{{ trait.location_repr }}</td> - <td data-export="{{ '%0.3f' % trait.mean|float }}" align="right">{{ '%0.3f' % trait.mean|float }}</td> - <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2={% if trait.dataset.name == 'Temp' %}Temp_{{ trait.dataset.group.name }}{% else %}{{ trait.dataset.name }}{% endif %}&trait_1={{ this_trait.name }}&trait_2={{ trait.name }}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> - <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> - <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> - {% if trait.lit_corr == "" or trait.lit_corr == 0.000 %} - <td data-export="--" align="right">--</td> - {% else %} - <td data-export="{{ '%0.3f'|format(trait.lit_corr) }}" align="right">{{ '%0.3f'|format(trait.lit_corr) }}</td> - {% endif %} - {% if trait.tissue_corr == "" or trait.tissue_corr == 0.000 %} - <td data-export="--" align="right">--</td> - <td data-export="--" align="right">--</td> - {% else %} - <td data-export="{{ '%0.3f'|format(trait.tissue_corr) }}" align="right">{{ '%0.3f'|format(trait.tissue_corr) }}</td> - <td data-export="{{ '%0.3e'|format(trait.tissue_pvalue) }}" align="right">{{ '%0.3e'|format(trait.tissue_pvalue) }}</td> - {% endif %} - <td data-export={% if trait.LRS_score_repr != "N/A" %}"{{ '%0.1f' % trait.LRS_score_repr|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> - <td data-export="{{ trait.LRS_location_repr }}" align="right">{{ trait.LRS_location_repr }}</td> - <td data-export={% if trait.additive != "" %}"{{ '%0.3f' % trait.additive|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> - {% elif target_dataset.type == "Publish" %} - {% if trait.abbreviation %} - <td title="{{ trait.abbreviation }}" data-export="{{ trait.abbreviation }}">{% if trait.abbreviation|length > 20 %}{{ trait.abbreviation[:20] }}...{% else %}{{ trait.abbreviation }}{% endif %}</td> - {% else %} - <td data-export="N/A">N/A</td> - {% endif %} - <td data-export="{{ trait.description_display }}">{% if trait.description_display|length > 70 %}{{ trait.description_display[:70] }}...{% else %}{{ trait.description_display }}{% endif %}</td> - {% if trait.authors %} - {% set authors_list = trait.authors.split(',') %} - <td data-export="{{ trait.authors }}">{% if authors_list|length > 6 %}{{ authors_list[:6]|join(', ') }}, et al.{% else %}{{ trait.authors }}{% endif %}</td> - {% else %} - <td data-export="N/A">N/A</td> - {% endif %} - <td data-export="{{ trait.pubmed_text }}"> - {% if trait.pubmed_text != "N/A" %} - <a href="{{ trait.pubmed_link }}"> - {{ trait.pubmed_text }} - </a> - {% else %} - {{ trait.pubmed_text }} - {% endif %} - </td> - <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2={{ trait.dataset.name }}&trait_1={{ this_trait.name }}&trait_2={{ trait.name }}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> - <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> - <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> - <td data-export="{{ trait.LRS_score_repr }}" align="right">{{ trait.LRS_score_repr }}</td> - <td data-export="{{ trait.LRS_location_repr }}" align="right">{{ trait.LRS_location_repr }}</td> - <td data-export={% if trait.additive != "" %}"{{ '%0.3f' % trait.additive|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> - {% elif target_dataset.type == "Geno" %} - <td data-export="{{ trait.location_repr }}" align="right">{{ trait.location_repr }}</TD> - <td data-export="{{ '%0.3f'|format(trait.sample_r) }}"" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2={{ trait.dataset.name }}&trait_1={{ this_trait.name }}&trait_2={{ trait.name }}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> - <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> - <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> - {% endif %} - </tr> - {% endfor %} + <td colspan="100%" align="center"><br><b><font size="15">Loading...</font></b><br></td> </tbody> </table> </div> @@ -332,14 +262,6 @@ {% if target_dataset.type == "ProbeSet" %} table_conf = { - "drawCallback": function( settings ) { - $('#trait_table tr').click(function(event) { - if (event.target.type !== 'checkbox') { - $(':checkbox', this).trigger('click'); - } - }); - $('.trait_checkbox:checkbox').on("change", change_buttons); - }, buttons: [ { extend: 'columnsToggle', @@ -353,40 +275,253 @@ postfixButtons: [ 'colvisRestore' ] } ], + "data": table_json, + "columns": [ + { + 'data': null, + 'width': "25px", + 'orderDataType': "dom-checkbox", + 'orderSequence': [ "desc", "asc"], + 'render': function(data, type, row, meta) { + return '<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" value="' + data.hmac + '">' + } + }, + { + 'title': "Index", + 'type': "natural", + 'width': "30px", + 'data': "index" + }, + { + 'title': "Record", + 'type': "natural-minus-na", + 'data': null, + 'width': "60px", + 'render': function(data, type, row, meta) { + return '<a target="_blank" href="/show_trait?trait_id=' + data.trait_id + '&dataset=' + data.dataset + '">' + data.trait_id + '</a>' + } + }{% if target_dataset.type == 'ProbeSet' %}, + { + 'title': "Symbol", + 'type': "natural", + 'width': "120px", + 'data': "symbol" + }, + { + 'title': "Description", + 'type': "natural", + 'data': null, + 'render': function(data, type, row, meta) { + try { + return decodeURIComponent(escape(data.description)) + } catch(err){ + return escape(data.description) + } + } + }, + { + 'title': "Location", + 'type': "natural-minus-na", + 'width': "125px", + 'data': "location" + }, + { + 'title': "Mean", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "mean", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "sample_r", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "N", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "num_overlap", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "sample_p", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Lit {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "lit_corr", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Tissue {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "tissue_corr", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Tissue p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "tissue_pvalue", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'type': "natural-minus-na", + 'data': "lrs_score", + 'width': "60px", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Peak Location", + 'type': "natural-minus-na", + 'width': "125px", + 'data': "lrs_location" + }, + { + 'title': "Effect Size<a href=\"http://gn1.genenetwork.org/glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'type': "natural-minus-na", + 'data': "additive", + 'width': "85px", + 'orderSequence': [ "desc", "asc"] + }{% elif target_dataset.type == 'Publish' %}, + { + 'title': "Abbreviation", + 'type': "natural", + 'width': "500px", + 'data': null, + 'render': function(data, type, row, meta) { + try { + return decodeURIComponent(escape(data.abbreviation)) + } catch(err){ + return data.abbreviation + } + } + }, + { + 'title': "Description", + 'type': "natural", + 'width': "500px", + 'data': null, + 'render': function(data, type, row, meta) { + try { + return decodeURIComponent(escape(data.description)) + } catch(err){ + return data.description + } + } + }, + { + 'title': "Authors", + 'type': "natural", + 'width': "500px", + 'data': null, + 'render': function(data, type, row, meta) { + try { + return decodeURIComponent(escape(data.authors_display)) + } catch(err){ + return data.authors_display + } + }, + { + 'title': "Year", + 'type': "natural-minus-na", + 'data': null, + 'width': "80px", + 'render': function(data, type, row, meta) { + if (data.pubmed_id != "N/A"){ + return '<a href="' + data.pubmed_link + '">' + data.pubmed_text + '</a>' + } else { + return data.pubmed_text + } + }, + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "sample_r", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "N", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "num_overlap", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "sample_p", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'type': "natural-minus-na", + 'data': "lrs_score", + 'width': "60px", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Peak Location", + 'type': "natural-minus-na", + 'width': "125px", + 'data': "lrs_location" + }, + { + 'title': "Effect Size<a href=\"http://gn1.genenetwork.org/glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'type': "natural-minus-na", + 'data': "additive", + 'width': "85px", + 'orderSequence': [ "desc", "asc"] + }{% elif dataset.type == 'Geno' %}, + { + 'title': "Location", + 'type': "natural-minus-na", + 'width': "120px", + 'data': "location" + }, + { + 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "sample_r", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "N", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "num_overlap", + 'orderSequence': [ "desc", "asc"] + }, + { + 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", + 'type': "natural-minus-na", + 'width': "40px", + 'data': "sample_p", + 'orderSequence': [ "desc", "asc"] + }{% endif %} + ], "columnDefs": [ { "targets": 0, "orderable": false } ], - "columns": [ - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural", "width": "15%" }, - { "type": "natural" }, - { "type": "natural" }, - { "orderDataType": "dom-innertext", 'orderSequence': [ "desc", "asc"] }, - { "type": "natural" }, - { "type": "scientific" }, - { "type": "natural-minus-na", 'orderSequence': [ "desc", "asc"] }, - { "type": "natural-minus-na", 'orderSequence': [ "desc", "asc"] }, - { "type": "scientific" }, - { "type": "natural-minus-na" }, - { "type": "natural-minus-na" }, - { "type": "natural-minus-na" } - ], - "createdRow": function ( row, data, index ) { - $('td', row).eq(4).attr('title', $('td', row).eq(4).text()); - if ($('td', row).eq(4).text().length > 40) { - $('td', row).eq(4).text($('td', row).eq(4).text().substring(0, 40)); - $('td', row).eq(4).text($('td', row).eq(4).text() + '...') - } - }, "order": [[9, "asc" ]], - "sDom": "Btir", - "iDisplayLength": -1, - "autoWidth": false, - "deferRender": true, + "sDom": "Bpitirp", + "autoWidth": true, "bSortClasses": false, "scrollY": "50vh", "scroller": true, @@ -438,6 +573,7 @@ "sDom": "Btir", "iDisplayLength": -1, "autoWidth": false, + "processing": true, "deferRender": true, "bSortClasses": false, "scrollY": "50vh", @@ -486,6 +622,12 @@ the_table = $('#trait_table').DataTable(table_conf); + the_table.on( 'order.dt search.dt draw.dt', function () { + the_table.column(1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) { + cell.innerHTML = i+1; + } ); + } ).draw(); + console.timeEnd("Creating table"); submit_special = function(url) { -- cgit v1.2.3 From b695ea7f5ee11c80c9b1c547fedd1216b459acd4 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 10 Nov 2020 13:01:23 -0600 Subject: Added CSS file for all pages that include a table of traits --- wqflask/wqflask/static/new/css/trait_list.css | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 wqflask/wqflask/static/new/css/trait_list.css (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/css/trait_list.css b/wqflask/wqflask/static/new/css/trait_list.css new file mode 100644 index 00000000..87bd244e --- /dev/null +++ b/wqflask/wqflask/static/new/css/trait_list.css @@ -0,0 +1,34 @@ +div.tool-button-container { + min-width: 950px; +} + +div.collection-table-options { + min-width: 1100px; +} + +div.show-hide-container { + margin-bottom: 5px; + margin-top: 10px; +} + +/* div.dts_label { + position: absolute; + right: 10px; + background: rgba(0, 0, 0, 0.8); + color: white; + box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5); + text-align: right; + border-radius: 3px; + padding: 0.4em; + z-index: 2; + display: none; +} */ + +table.dataTable tbody td { + /* word-wrap: break-word; + word-break: break-all; */ + overflow: hidden; + max-width: 500px; + overflow-wrap: break-word; + text-overflow: ellipsis; +} \ No newline at end of file -- cgit v1.2.3 From 4f9a389795d3ecade1a988347c834103f258e6dc Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 10 Nov 2020 14:15:43 -0600 Subject: * wqflask/wqflask/correlation/show_corr_results.py - Changed some of the parameters sent to the correlation table * wqflask/wqflask/templates_correlation_page.html - Fixed some column defs and removed unused table configuration code --- wqflask/wqflask/correlation/show_corr_results.py | 22 +++-- wqflask/wqflask/templates/correlation_page.html | 120 +++-------------------- 2 files changed, 26 insertions(+), 116 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index ebfea8fe..07b45860 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -522,19 +522,19 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) elif target_dataset.type == "Publish": - results_dict['abbreviation'] = trait.abbreviation - if len(trait.abbreviation) > 20: + results_dict['abbreviation'] = "N/A" + if trait.abbreviation and len(trait.abbreviation) > 20: results_dict['abbreviation_display'] = trait.abbreviation[:20] + "..." else: results_dict['abbreviation_display'] = trait.abbreviation - if len(trait.description_display) > 40: - results_dict['description'] = trait.description_display[:40] + "..." - else: - results_dict['description'] = trait.description_display + # if len(trait.description_display) > 40: + # results_dict['description'] = trait.description_display[:40] + "..." + # else: + results_dict['description'] = trait.description_display results_dict['authors'] = trait.authors authors_list = trait.authors.split(',') - if len(authors_list > 6): - results_dict['authors_display'] = authors_list[:6].join(", ") + ", et al." + if len(authors_list) > 6: + results_dict['authors_display'] = ", ".join(authors_list[:6]) + ", et al." else: results_dict['authors_display'] = trait.authors if trait.pubmed_id: @@ -542,13 +542,15 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['pubmed_id'] = trait.pubmed_id results_dict['year'] = trait.pubmed_text else: - results_dict['pubmed'] = "<a href='" + trait.pubmed_link + "'> " + trait.pubmed_text + "</a>" + results_dict['pubmed_link'] = trait.pubmed_link + results_dict['pubmed_text'] = trait.pubmed_text else: if for_api: results_dict['pubmed_id'] = "N/A" results_dict['year'] = "N/A" else: - results_dict['pubmed'] = "N/A" + results_dict['pubmed_link'] = "N/A" + results_dict['pubmed_text'] = "N/A" results_dict['lrs_score'] = trait.LRS_score_repr results_dict['lrs_location'] = trait.LRS_location_repr if trait.additive and trait.additive != "": diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 6f92fcb5..2b79770a 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -260,7 +260,6 @@ console.time("Creating table"); - {% if target_dataset.type == "ProbeSet" %} table_conf = { buttons: [ { @@ -400,10 +399,10 @@ 'width': "500px", 'data': null, 'render': function(data, type, row, meta) { - try { - return decodeURIComponent(escape(data.abbreviation)) - } catch(err){ - return data.abbreviation + try { + return decodeURIComponent(escape(data.abbreviation)) + } catch(err){ + return data.abbreviation } } }, @@ -413,10 +412,10 @@ 'width': "500px", 'data': null, 'render': function(data, type, row, meta) { - try { - return decodeURIComponent(escape(data.description)) - } catch(err){ - return data.description + try { + return decodeURIComponent(escape(data.description)) + } catch(err){ + return data.description } } }, @@ -426,11 +425,12 @@ 'width': "500px", 'data': null, 'render': function(data, type, row, meta) { - try { - return decodeURIComponent(escape(data.authors_display)) - } catch(err){ - return data.authors_display + try { + return decodeURIComponent(escape(data.authors_display)) + } catch(err){ + return data.authors_display } + } }, { 'title': "Year", @@ -520,7 +520,7 @@ "orderable": false } ], "order": [[9, "asc" ]], - "sDom": "Bpitirp", + "sDom": "Bitir", "autoWidth": true, "bSortClasses": false, "scrollY": "50vh", @@ -528,98 +528,6 @@ "scrollCollapse": true } - {% elif target_dataset.type == "Publish" %} - table_conf = { - "drawCallback": function( settings ) { - $('#trait_table tr').click(function(event) { - if (event.target.type !== 'checkbox') { - $(':checkbox', this).trigger('click'); - } - }); - $('.trait_checkbox:checkbox').on("change", change_buttons); - }, - "buttons": [ - { - extend: 'columnsToggle', - columns: function( idx, data, node ) { - if (idx != 0) { - return true; - } else { - return false; - } - }, - postfixButtons: [ 'colvisRestore' ] - } - ], - "columnDefs": [ - { "targets": 0, "orderable": false } - ], - "columns": [ - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural", "width": "20%" }, - { "type": "natural", "width": "12%" }, - { "type": "natural-minus-na" }, - { "orderDataType": "dom-innertext", 'orderSequence': [ "desc", "asc"] }, - { "type": "natural" }, - { "type": "scientific" }, - { "type": "natural-minus-na" }, - { "type": "natural-minus-na" }, - { "type": "natural-minus-na" } - ], - "order": [[9, "asc" ]], - "sDom": "Btir", - "iDisplayLength": -1, - "autoWidth": false, - "processing": true, - "deferRender": true, - "bSortClasses": false, - "scrollY": "50vh", - "scroller": true, - "scrollCollapse": true - } - {% elif target_dataset.type == "Geno" %} - table_conf = { - "paging": false, - buttons: [ - { - extend: 'columnsToggle', - columns: function( idx, data, node ) { - if (idx != 0) { - return true; - } else { - return false; - } - }, - postfixButtons: [ 'colvisRestore' ] - } - ], - "columnDefs": [ - { "targets": 0, "orderable": false } - ], - "columns": [ - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "type": "natural" }, - { "orderDataType": "dom-innertext", 'orderSequence': [ "desc", "asc"] }, - { "type": "natural-minus-na" }, - { "type": "scientific" } - ], - "order": [[6, "asc" ]], - "sDom": "Btir", - "autoWidth": false, - "bDeferRender": true, - "scrollY": "800px", - "scrollCollapse": false, - "scrollY": "50vh", - "scroller": true, - "scrollCollapse": true - } - {% endif %} - the_table = $('#trait_table').DataTable(table_conf); the_table.on( 'order.dt search.dt draw.dt', function () { -- cgit v1.2.3 From a40538d382b334b2fcb52c1f9bccbe0533ddbaba Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 11 Nov 2020 12:55:36 -0600 Subject: Switched checking if a trait is confidential to checking if it has a pubmed ID for the purposes of showing pre-publication abbreviation/description --- wqflask/base/trait.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index cfc02f8b..e0afa915 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -513,7 +513,7 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False): # If the dataset is confidential and the user has access to confidential # phenotype traits, then display the pre-publication description instead # of the post-publication description - if trait.confidential: + if not trait.pubmed_id: trait.abbreviation = trait.pre_publication_abbreviation trait.description_display = trait.pre_publication_description else: -- cgit v1.2.3 From 486b30324d67971f9fa9e741cf1c7f24d286dad2 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 11 Nov 2020 12:57:20 -0600 Subject: - Fixed an issue causing the phenotype abbreviation to not be displayed properly in correlation results - Set default description to N/A when there's no trait description for phenotype traits --- wqflask/wqflask/correlation/show_corr_results.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 07b45860..394c113d 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -522,15 +522,12 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) elif target_dataset.type == "Publish": - results_dict['abbreviation'] = "N/A" - if trait.abbreviation and len(trait.abbreviation) > 20: - results_dict['abbreviation_display'] = trait.abbreviation[:20] + "..." - else: + results_dict['abbreviation_display'] = "N/A" + if trait.abbreviation: results_dict['abbreviation_display'] = trait.abbreviation - # if len(trait.description_display) > 40: - # results_dict['description'] = trait.description_display[:40] + "..." - # else: - results_dict['description'] = trait.description_display + results_dict['description'] = "N/A" + if trait.description_display: + results_dict['description'] = trait.description_display results_dict['authors'] = trait.authors authors_list = trait.authors.split(',') if len(authors_list) > 6: -- cgit v1.2.3 From e20d5f41d076659706442a8ab1db93cd65c9cb0f Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 11 Nov 2020 12:58:17 -0600 Subject: Changed some column widths and removed the width for description so it can vary with page width --- wqflask/wqflask/templates/correlation_page.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 2b79770a..bb7d3df6 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -396,20 +396,19 @@ { 'title': "Abbreviation", 'type': "natural", - 'width': "500px", + 'width': "200px", 'data': null, 'render': function(data, type, row, meta) { try { - return decodeURIComponent(escape(data.abbreviation)) + return decodeURIComponent(escape(data.abbreviation_display)) } catch(err){ - return data.abbreviation + return data.abbreviation_display } } }, { 'title': "Description", 'type': "natural", - 'width': "500px", 'data': null, 'render': function(data, type, row, meta) { try { @@ -422,7 +421,7 @@ { 'title': "Authors", 'type': "natural", - 'width': "500px", + 'width': "400px", 'data': null, 'render': function(data, type, row, meta) { try { -- cgit v1.2.3 From 26d882e2f1599bce23ec61501c49825c62707cac Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 13:37:00 -0600 Subject: Replaced superscript i's for glossary links in search result table headers with fontawesome icons --- wqflask/wqflask/templates/search_result_page.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 36f144c2..c163a99a 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -4,6 +4,7 @@ <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/scroller/css/scroller.dataTables.min.css') }}"> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> + <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> <link rel="stylesheet" type="text/css" href="static/new/css/trait_list.css" /> {% endblock %} @@ -184,6 +185,7 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script> + <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script> @@ -331,10 +333,10 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "High P<a href=\"{{ url_for('glossary_blueprint.glossary') }}#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "High P<a href=\"{{ url_for('glossary_blueprint.glossary') }}#LRS\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "lrs_score", - 'width': "60px", + 'width': "65px", 'orderSequence': [ "desc", "asc"] }, { @@ -344,10 +346,10 @@ 'data': "lrs_location" }, { - 'title': "Effect Size<a href=\"{{ url_for('glossary_blueprint.glossary') }}#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "Effect Size<a href=\"{{ url_for('glossary_blueprint.glossary') }}#A\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "additive", - 'width': "85px", + 'width': "90px", 'orderSequence': [ "desc", "asc"] }{% elif dataset.type == 'Publish' %}, { @@ -400,7 +402,7 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "High P<a href=\"{{ url_for('glossary_blueprint.glossary') }}#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "High P<a href=\"{{ url_for('glossary_blueprint.glossary') }}#LRS\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "lrs_score", 'width': "80px", @@ -413,7 +415,7 @@ 'data': "lrs_location" }, { - 'title': "Effect Size<a href=\"{{ url_for('glossary_blueprint.glossary') }}#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "Effect Size<a href=\"{{ url_for('glossary_blueprint.glossary') }}#A\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'width': "120px", 'data': "additive", -- cgit v1.2.3 From db0e80bef73eb163bfb747ec4d137d5c5069ade8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 13:40:40 -0600 Subject: Added cdn imports for fontawesome to correlation page and changed superscript i's to fontawesome icons for the glossary links in column headers --- wqflask/wqflask/templates/correlation_page.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index bb7d3df6..6ea86609 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -4,6 +4,7 @@ <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> + <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} {% block content %} @@ -145,7 +146,8 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> - <script type="text/javascript" src="https://cdn.datatables.net/scroller/2.0.2/js/dataTables.scroller.min.js"></script> + <script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js"></script> + <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/scroller/2.0.2/js/dataTables.scroller.min.js"></script> <script type="text/javascript" charset="utf-8"> var table_json = {{ json_results | safe }} @@ -374,7 +376,7 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "lrs_score", 'width': "60px", @@ -387,7 +389,7 @@ 'data': "lrs_location" }, { - 'title': "Effect Size<a href=\"http://gn1.genenetwork.org/glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "Effect Size<a href=\"http://gn1.genenetwork.org/glossary.html#A\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "additive", 'width': "85px", @@ -467,7 +469,7 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "lrs_score", 'width': "60px", @@ -480,7 +482,7 @@ 'data': "lrs_location" }, { - 'title': "Effect Size<a href=\"http://gn1.genenetwork.org/glossary.html#A\" target=\"_blank\" style=\"color: white;\"><sup style=\"font-size: small; color: #FF0000;\"> ?</sup></a>", + 'title': "Effect Size<a href=\"http://gn1.genenetwork.org/glossary.html#A\" target=\"_blank\" style=\"color: white;\"> <i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>", 'type': "natural-minus-na", 'data': "additive", 'width': "85px", -- cgit v1.2.3 From 92848edd669925dfd3c9e0722a99fd39dbbfd4b8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 14:14:23 -0600 Subject: Changed some if/else statements to just initializing the variables + the if statement and fixed "lrs_location" to "location" for target genotypes --- wqflask/wqflask/correlation/show_corr_results.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 394c113d..17d3de54 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -489,25 +489,20 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['dataset'] = trait.dataset.name if target_dataset.type == "ProbeSet": results_dict['symbol'] = trait.symbol - if len(trait.description_display) > 40: - results_dict['description'] = trait.description_display[:40] + "..." - else: - results_dict['description'] = trait.description_display - results_dict['description'] = trait.description_display + results_dict['description'] = "N/A" results_dict['location'] = trait.location_repr + results_dict['mean'] = "N/A" + results_dict['lrs_score'] = "N/A" + results_dict['additive'] = "N/A" + if trait.description_display: + results_dict['description'] = trait.description_display if trait.mean and trait.mean != "": results_dict['mean'] = float(trait.mean) - else: - results_dict['mean'] = "N/A" if trait.LRS_score_repr != "N/A": results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) - else: - results_dict['lrs_score'] = "N/A" results_dict['lrs_location'] = trait.LRS_location_repr if trait.additive and trait.additive != "": results_dict['additive'] = "%0.3f" % float(trait.additive) - else: - results_dict['additive'] = "N/A" results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) @@ -558,7 +553,7 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) else: - results_dict['lrs_location'] = trait.LRS_location_repr + results_dict['location'] = trait.location_repr results_dict['sample_r'] = "%0.3f" % trait.sample_r results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) -- cgit v1.2.3 From 3af4d8f5b7e573a9cee82de19cbbfc644e27143e Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 15:13:58 -0600 Subject: Added some css to trait_list.css restyling the "show/hide column" buttons when they're active. Not really pleased with the result, but styling a button to look depressed is a pain --- wqflask/wqflask/static/new/css/trait_list.css | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/css/trait_list.css b/wqflask/wqflask/static/new/css/trait_list.css index 691dcb12..b83655da 100644 --- a/wqflask/wqflask/static/new/css/trait_list.css +++ b/wqflask/wqflask/static/new/css/trait_list.css @@ -1,12 +1,20 @@ -div.tool-button-container { - min-width: 950px; -} - -div.collection-table-options { - min-width: 1100px; -} - -div.show-hide-container { - margin-bottom: 5px; - margin-top: 10px; -} \ No newline at end of file +div.tool-button-container { + min-width: 950px; +} + +div.collection-table-options { + min-width: 1100px; +} + +div.show-hide-container { + margin-bottom: 5px; + margin-top: 10px; +} + +button.active { + background: #e5e5e5; + -webkit-box-shadow: inset 0px 0px 5px #c1c1c1; + -moz-box-shadow: inset 0px 0px 5px #c1c1c1; + box-shadow: inset 0px 0px 5px #c1c1c1; + outline: none; + } \ No newline at end of file -- cgit v1.2.3 From 975fb0a19feafaf0f2c9a9dbcd88b96a3439196a Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 15:15:10 -0600 Subject: - Added Show/Hide Columns options and included the trait_list.css file which including styling for said options - Changed some column widths to avoid text wrapping --- wqflask/wqflask/templates/correlation_page.html | 73 +++++++++++++++++++++---- 1 file changed, 61 insertions(+), 12 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 6ea86609..3d543c35 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -5,6 +5,7 @@ <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" /> <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"> + <link rel="stylesheet" type="text/css" href="/static/new/css/trait_list.css" /> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} {% block content %} @@ -113,10 +114,38 @@ </div> {% endif %} </div> - <div style="margin-bottom: 5px;"> - <b>Show/Hide Columns:</b> + <div class="show-hide-container"> + <b>Show/Hide Columns:</b> + <br> + <button class="toggle-vis" data-column="1">Index</button> + <button class="toggle-vis" data-column="2">Record</button> + {% if target_dataset.type == 'ProbeSet' %} + <button class="toggle-vis" data-column="3">Symbol</button> + <button class="toggle-vis" data-column="4">Description</button> + <button class="toggle-vis" data-column="5">Location</button> + <button class="toggle-vis" data-column="6">Mean</button> + <button class="toggle-vis" data-column="7">High P</button> + <button class="toggle-vis" data-column="8">Peak Location</button> + <button class="toggle-vis" data-column="9">Effect Size</button> + {% elif target_dataset.type == 'Publish' %} + <button class="toggle-vis" data-column="3">Abbreviation</button> + <button class="toggle-vis" data-column="4">Description</button> + <button class="toggle-vis" data-column="5">Authors</button> + <button class="toggle-vis" data-column="6">Year</button> + <button class="toggle-vis" data-column="7">Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}</button> + <button class="toggle-vis" data-column="8">N</button> + <button class="toggle-vis" data-column="9">Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})</button> + <button class="toggle-vis" data-column="10">High P</button> + <button class="toggle-vis" data-column="11">Peak Location</button> + <button class="toggle-vis" data-column="12">Effect Size</button> + {% else %} + <button class="toggle-vis" data-column="3">Location</button> + <button class="toggle-vis" data-column="4">Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}</button> + <button class="toggle-vis" data-column="5">N</button> + <button class="toggle-vis" data-column="6">Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})</button> + {% endif %} </div> - <div style="width: 100%; min-width: {% if target_dataset.type == "ProbeSet" %}1700px{% elif target_dataset.type == "Publish" %}1600px{% else %}600px{% endif %};"> + <div style="width: 100%; {% if target_dataset.type == "ProbeSet" %}min-width: 1700px;{% elif target_dataset.type == "Publish" %}min-width: 1600px;{% else %}width: 650px;{% endif %}"> <table id="trait_table" class="table-hover table-striped cell-border" style="float: left;"> <thead> <tr> @@ -350,7 +379,7 @@ { 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", 'type': "natural-minus-na", - 'width': "40px", + 'width': "65px", 'data': "sample_p", 'orderSequence': [ "desc", "asc"] }, @@ -464,7 +493,7 @@ { 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", 'type': "natural-minus-na", - 'width': "40px", + 'width': "65px", 'data': "sample_p", 'orderSequence': [ "desc", "asc"] }, @@ -487,7 +516,7 @@ 'data': "additive", 'width': "85px", 'orderSequence': [ "desc", "asc"] - }{% elif dataset.type == 'Geno' %}, + }{% elif target_dataset.type == 'Geno' %}, { 'title': "Location", 'type': "natural-minus-na", @@ -511,7 +540,7 @@ { 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", 'type': "natural-minus-na", - 'width': "40px", + 'width': "65px", 'data': "sample_p", 'orderSequence': [ "desc", "asc"] }{% endif %} @@ -520,8 +549,12 @@ "targets": 0, "orderable": false } ], + {% if target_dataset.type == 'Geno' %} + "order": [[6, "asc" ]], + {% else %} "order": [[9, "asc" ]], - "sDom": "Bitir", + {% endif %} + "sDom": "itir", "autoWidth": true, "bSortClasses": false, "scrollY": "50vh", @@ -529,16 +562,32 @@ "scrollCollapse": true } - the_table = $('#trait_table').DataTable(table_conf); + trait_table = $('#trait_table').DataTable(table_conf); - the_table.on( 'order.dt search.dt draw.dt', function () { - the_table.column(1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) { + trait_table.on( 'order.dt search.dt draw.dt', function () { + trait_table.column(1, {search:'applied', order:'applied'}).nodes().each( function (cell, i) { cell.innerHTML = i+1; } ); } ).draw(); console.timeEnd("Creating table"); + $('.toggle-vis').on( 'click', function (e) { + e.preventDefault(); + + // Get the column API object + var column = trait_table.column( $(this).attr('data-column') ); + + // Toggle the visibility + column.visible( ! column.visible() ); + + if (column.visible()){ + $(this).removeClass("active"); + } else { + $(this).addClass("active"); + } + } ); + submit_special = function(url) { $("#correlation_form").attr("action", url); return $("#correlation_form").submit(); @@ -555,7 +604,7 @@ $("#select_traits").click(function() { console.log("redrawing") - the_table.draw(); + trait_table.draw(); }); }); </script> -- cgit v1.2.3 From 76d5b24b3d2e0b5e6be5b1cf4c125a9a812ff57a Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 15:25:32 -0600 Subject: Switched to using boolean casting to check if various trait attributes exist --- wqflask/wqflask/correlation/show_corr_results.py | 59 ++++++++++++------------ 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 17d3de54..87dd7597 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -494,61 +494,60 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['mean'] = "N/A" results_dict['lrs_score'] = "N/A" results_dict['additive'] = "N/A" - if trait.description_display: + if bool(trait.description_display): results_dict['description'] = trait.description_display - if trait.mean and trait.mean != "": + if bool(trait.mean): results_dict['mean'] = float(trait.mean) if trait.LRS_score_repr != "N/A": results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) results_dict['lrs_location'] = trait.LRS_location_repr - if trait.additive and trait.additive != "": + if bool(trait.additive): results_dict['additive'] = "%0.3f" % float(trait.additive) results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) - if trait.lit_corr == "" or trait.lit_corr == 0: - results_dict['lit_corr'] = "--" - else: + results_dict['lit_corr'] = "--" + results_dict['tissue_corr'] = "--" + results_dict['tissue_pvalue'] = "--" + if bool(trait.lit_corr): results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr) - if trait.tissue_corr == "" or trait.tissue_corr == 0: - results_dict['tissue_corr'] = "--" - results_dict['tissue_pvalue'] = "--" - else: + if bool(trait.tissue_corr): results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) elif target_dataset.type == "Publish": results_dict['abbreviation_display'] = "N/A" - if trait.abbreviation: - results_dict['abbreviation_display'] = trait.abbreviation results_dict['description'] = "N/A" - if trait.description_display: - results_dict['description'] = trait.description_display - results_dict['authors'] = trait.authors - authors_list = trait.authors.split(',') - if len(authors_list) > 6: - results_dict['authors_display'] = ", ".join(authors_list[:6]) + ", et al." + results_dict['authors_display'] = "N/A" + results_dict['additive'] = "N/A" + if for_api: + results_dict['pubmed_id'] = "N/A" + results_dict['year'] = "N/A" else: - results_dict['authors_display'] = trait.authors - if trait.pubmed_id: + results_dict['pubmed_link'] = "N/A" + results_dict['pubmed_text'] = "N/A" + + if bool(trait.abbreviation): + results_dict['abbreviation_display'] = trait.abbreviation + if bool(trait.description_display): + results_dict['description'] = trait.description_display + if bool(trait.authors): + authors_list = trait.authors.split(',') + if len(authors_list) > 6: + results_dict['authors_display'] = ", ".join(authors_list[:6]) + ", et al." + else: + results_dict['authors_display'] = trait.authors + if bool(trait.pubmed_id): if for_api: results_dict['pubmed_id'] = trait.pubmed_id results_dict['year'] = trait.pubmed_text else: results_dict['pubmed_link'] = trait.pubmed_link results_dict['pubmed_text'] = trait.pubmed_text - else: - if for_api: - results_dict['pubmed_id'] = "N/A" - results_dict['year'] = "N/A" - else: - results_dict['pubmed_link'] = "N/A" - results_dict['pubmed_text'] = "N/A" + results_dict['lrs_score'] = trait.LRS_score_repr results_dict['lrs_location'] = trait.LRS_location_repr - if trait.additive and trait.additive != "": + if bool(trait.additive): results_dict['additive'] = "%0.3f" % float(trait.additive) - else: - results_dict['additive'] = "N/A" results_dict['sample_r'] = "%0.3f" % trait.sample_r results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) -- cgit v1.2.3 From 678d9cd4e073c3936c34d3b9b54f1e6c590def27 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 15:37:49 -0600 Subject: Switched to using f-strings instead of the older method of string formatting --- wqflask/wqflask/correlation/show_corr_results.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 87dd7597..1b801b1d 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -499,21 +499,21 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap if bool(trait.mean): results_dict['mean'] = float(trait.mean) if trait.LRS_score_repr != "N/A": - results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) + results_dict['lrs_score'] = f"{float(trait.LRS_score_repr):.1f}" results_dict['lrs_location'] = trait.LRS_location_repr if bool(trait.additive): - results_dict['additive'] = "%0.3f" % float(trait.additive) - results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) + results_dict['additive'] = f"{float(trait.additive):.3f}" + results_dict['sample_r'] = f"{float(trait.sample_r):.3f}" results_dict['num_overlap'] = trait.num_overlap - results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + results_dict['sample_p'] = f"{float(trait.sample_p):.3e}" results_dict['lit_corr'] = "--" results_dict['tissue_corr'] = "--" results_dict['tissue_pvalue'] = "--" if bool(trait.lit_corr): - results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr) + results_dict['lit_corr'] = f"{float(trait.lit_corr):.3f}" if bool(trait.tissue_corr): - results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) - results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) + results_dict['tissue_corr'] = f"{float(trait.tissue_corr):.3f}" + results_dict['tissue_pvalue'] = f"{float(trait.tissue_pvalue):.3e}" elif target_dataset.type == "Publish": results_dict['abbreviation_display'] = "N/A" results_dict['description'] = "N/A" @@ -547,15 +547,15 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['lrs_score'] = trait.LRS_score_repr results_dict['lrs_location'] = trait.LRS_location_repr if bool(trait.additive): - results_dict['additive'] = "%0.3f" % float(trait.additive) - results_dict['sample_r'] = "%0.3f" % trait.sample_r + results_dict['additive'] = f"{float(trait.additive):.3f}" + results_dict['sample_r'] = f"{float(trait.sample_r):.3f}" results_dict['num_overlap'] = trait.num_overlap - results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + results_dict['sample_p'] = f"{float(trait.sample_p):.3e}" else: results_dict['location'] = trait.location_repr - results_dict['sample_r'] = "%0.3f" % trait.sample_r + results_dict['sample_r'] = f"{float(trait.sample_r):.3f}" results_dict['num_overlap'] = trait.num_overlap - results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + results_dict['sample_p'] = f"{float(trait.sample_p):.3e}" results_list.append(results_dict) -- cgit v1.2.3 From d2db01fd8e69afdc6c21b4be529674fffe62b830 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 25 Nov 2020 15:45:18 -0600 Subject: Fixed the "Reset Columns" button to work with the new way of showing/hiding columns (that no longer uses DataTables buttons plug-in) --- wqflask/wqflask/templates/correlation_page.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 3d543c35..6419b185 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -572,7 +572,7 @@ console.timeEnd("Creating table"); - $('.toggle-vis').on( 'click', function (e) { + $('.toggle-vis').on('click', function (e) { e.preventDefault(); // Get the column API object @@ -588,6 +588,12 @@ } } ); + $('#redraw').on('click', function (e) { + e.preventDefault(); + trait_table.columns().visible( true ); + $('.toggle-vis.active').removeClass('active'); + }); + submit_special = function(url) { $("#correlation_form").attr("action", url); return $("#correlation_form").submit(); -- cgit v1.2.3