aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/trait.py2
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py109
-rw-r--r--wqflask/wqflask/static/new/css/trait_list.css32
-rw-r--r--wqflask/wqflask/templates/correlation_page.html518
-rw-r--r--wqflask/wqflask/templates/search_result_page.html1
5 files changed, 393 insertions, 269 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 0f8f937c..ec8c40a0 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -516,7 +516,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:
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index 4c2b64ba..1b801b1d 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -484,75 +484,78 @@ 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
+ results_dict['dataset'] = trait.dataset.name
if target_dataset.type == "ProbeSet":
results_dict['symbol'] = trait.symbol
- results_dict['description'] = trait.description_display
+ results_dict['description'] = "N/A"
results_dict['location'] = trait.location_repr
- results_dict['mean'] = float(trait.mean)
+ results_dict['mean'] = "N/A"
+ results_dict['lrs_score'] = "N/A"
+ results_dict['additive'] = "N/A"
+ if bool(trait.description_display):
+ results_dict['description'] = trait.description_display
+ 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)
- else:
- results_dict['lrs_score'] = "N/A"
+ results_dict['lrs_score'] = f"{float(trait.LRS_score_repr):.1f}"
results_dict['lrs_location'] = trait.LRS_location_repr
- if 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>"
+ if bool(trait.additive):
+ 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)
- if trait.lit_corr == "" or trait.lit_corr == 0:
- results_dict['lit_corr'] = "--"
- else:
- results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr)
- if trait.tissue_corr == "" or trait.tissue_corr == 0:
- results_dict['tissue_corr'] = "--"
- else:
- results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr)
+ 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'] = f"{float(trait.lit_corr):.3f}"
+ if bool(trait.tissue_corr):
+ 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['description'] = trait.description_display
- results_dict['authors'] = trait.authors
- if trait.pubmed_id:
+ results_dict['abbreviation_display'] = "N/A"
+ results_dict['description'] = "N/A"
+ 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['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'] = "<a href='" + trait.pubmed_link + "'> " + trait.pubmed_text + "</a>"
- 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'] = trait.pubmed_link
+ results_dict['pubmed_text'] = trait.pubmed_text
+
results_dict['lrs_score'] = trait.LRS_score_repr
results_dict['lrs_location'] = trait.LRS_location_repr
- if 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>"
+ if bool(trait.additive):
+ 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['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['location'] = trait.location_repr
+ 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)
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
diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html
index bc0b592c..6419b185 100644
--- a/wqflask/wqflask/templates/correlation_page.html
+++ b/wqflask/wqflask/templates/correlation_page.html
@@ -2,9 +2,11 @@
{% 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="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 %}
<div class="container" style="min-width: 1250px;">
@@ -112,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>
@@ -127,77 +157,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>
@@ -215,6 +175,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 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 }}
@@ -329,16 +291,7 @@
console.time("Creating table");
- {% 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',
@@ -352,136 +305,295 @@
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': "65px",
+ '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;\">&nbsp;<i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></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;\">&nbsp;<i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>",
+ 'type': "natural-minus-na",
+ 'data': "additive",
+ 'width': "85px",
+ 'orderSequence': [ "desc", "asc"]
+ }{% elif target_dataset.type == 'Publish' %},
+ {
+ 'title': "Abbreviation",
+ 'type': "natural",
+ 'width': "200px",
+ 'data': null,
+ 'render': function(data, type, row, meta) {
+ try {
+ return decodeURIComponent(escape(data.abbreviation_display))
+ } catch(err){
+ return data.abbreviation_display
+ }
+ }
+ },
+ {
+ 'title': "Description",
+ 'type': "natural",
+ 'data': null,
+ 'render': function(data, type, row, meta) {
+ try {
+ return decodeURIComponent(escape(data.description))
+ } catch(err){
+ return data.description
+ }
+ }
+ },
+ {
+ 'title': "Authors",
+ 'type': "natural",
+ 'width': "400px",
+ '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': "65px",
+ 'data': "sample_p",
+ 'orderSequence': [ "desc", "asc"]
+ },
+ {
+ 'title': "High P<a href=\"http://gn1.genenetwork.org/glossary.html#LRS\" target=\"_blank\" style=\"color: white;\">&nbsp;<i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></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;\">&nbsp;<i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>",
+ 'type': "natural-minus-na",
+ 'data': "additive",
+ 'width': "85px",
+ 'orderSequence': [ "desc", "asc"]
+ }{% elif target_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': "65px",
+ '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() + '...')
- }
- },
+ {% if target_dataset.type == 'Geno' %}
+ "order": [[6, "asc" ]],
+ {% else %}
"order": [[9, "asc" ]],
- "sDom": "Btir",
- "iDisplayLength": -1,
- "autoWidth": false,
- "deferRender": true,
+ {% endif %}
+ "sDom": "itir",
+ "autoWidth": true,
"bSortClasses": false,
- "paging": false,
- "orderClasses": true
+ "scrollY": "50vh",
+ "scroller": true,
+ "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,
- "deferRender": true,
- "bSortClasses": false,
- "paging": false,
- "orderClasses": 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
- }
- {% endif %}
+ trait_table = $('#trait_table').DataTable(table_conf);
- the_table = $('#trait_table').DataTable(table_conf);
+ 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");
+ }
+ } );
+
+ $('#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();
@@ -498,7 +610,7 @@
$("#select_traits").click(function() {
console.log("redrawing")
- the_table.draw();
+ trait_table.draw();
});
});
</script>
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 9a28a78e..2a8d6931 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -5,6 +5,7 @@
<link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='fontawesome/css/font-awesome.min.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 %}