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(-) 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 %} - + {% endblock %} {% block content %}
@@ -127,77 +127,7 @@ - {% for trait in correlation_results %} - - - {{ loop.index }} - - - {{ trait.name }} - - - {% if target_dataset.type == 'ProbeSet' %} - {{ trait.symbol }} - {{ trait.description_display }} - {{ trait.location_repr }} - {{ '%0.3f' % trait.mean|float }} - {{ '%0.3f'|format(trait.sample_r) }} - {{ trait.num_overlap }} - {{ '%0.3e'|format(trait.sample_p) }} - {% if trait.lit_corr == "" or trait.lit_corr == 0.000 %} - -- - {% else %} - {{ '%0.3f'|format(trait.lit_corr) }} - {% endif %} - {% if trait.tissue_corr == "" or trait.tissue_corr == 0.000 %} - -- - -- - {% else %} - {{ '%0.3f'|format(trait.tissue_corr) }} - {{ '%0.3e'|format(trait.tissue_pvalue) }} - {% endif %} - {% if trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % trait.LRS_score_repr|float }}{% else %}N/A{% endif %} - {{ trait.LRS_location_repr }} - {% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %} - {% elif target_dataset.type == "Publish" %} - {% if trait.abbreviation %} - {% if trait.abbreviation|length > 20 %}{{ trait.abbreviation[:20] }}...{% else %}{{ trait.abbreviation }}{% endif %} - {% else %} - N/A - {% endif %} - {% if trait.description_display|length > 70 %}{{ trait.description_display[:70] }}...{% else %}{{ trait.description_display }}{% endif %} - {% if trait.authors %} - {% set authors_list = trait.authors.split(',') %} - {% if authors_list|length > 6 %}{{ authors_list[:6]|join(', ') }}, et al.{% else %}{{ trait.authors }}{% endif %} - {% else %} - N/A - {% endif %} - - {% if trait.pubmed_text != "N/A" %} - - {{ trait.pubmed_text }} - - {% else %} - {{ trait.pubmed_text }} - {% endif %} - - {{ '%0.3f'|format(trait.sample_r) }} - {{ trait.num_overlap }} - {{ '%0.3e'|format(trait.sample_p) }} - {{ trait.LRS_score_repr }} - {{ trait.LRS_location_repr }} - {% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %} - {% elif target_dataset.type == "Geno" %} - {{ trait.location_repr }} - {{ '%0.3f'|format(trait.sample_r) }} - {{ trait.num_overlap }} - {{ '%0.3e'|format(trait.sample_p) }} - {% endif %} - - {% endfor %} +
Loading...
@@ -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 '' + } + }, + { + '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 '' + data.trait_id + '' + } + }{% 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 ?", + '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 ?", + '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 '' + data.pubmed_text + '' + } 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 ?", + '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 ?", + '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