From e0626f40d8fe4fa83daba52b82c1b459b34b1849 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Tue, 2 Aug 2022 19:47:16 +0000
Subject: Define ROrRho and corr_method in JS to get rid of some of the
template logic that was mixed into the JS
---
wqflask/wqflask/templates/correlation_page.html | 32 +++++++++++++++----------
1 file changed, 20 insertions(+), 12 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html
index 8e9af648..c6cd2544 100644
--- a/wqflask/wqflask/templates/correlation_page.html
+++ b/wqflask/wqflask/templates/correlation_page.html
@@ -226,6 +226,14 @@
tableId = "trait_table";
+ {% if corr_method == 'pearson' %}
+ rOrRho = "r"
+ corr_method = "pearson"
+ {% else %}
+ rOrRho = "rho"
+ corr_method = "spearman"
+ {% endif %}
+
columnDefs = [
{
'data': null,
@@ -283,14 +291,14 @@
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}",
+ 'title': "Sample " + rOrRho,
'type': "natural-minus-na",
'width': "40px",
'data': null,
'orderSequence': [ "desc", "asc"],
'render': function(data) {
if (data.sample_r != "N/A") {
- return "" + data.sample_r + ""
+ return "" + data.sample_r + ""
} else {
return data.sample_r
}
@@ -304,28 +312,28 @@
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})",
+ 'title': "Sample p(" + rOrRho + ")",
'type': "scientific",
'width': "65px",
'data': "sample_p",
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Lit {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}",
+ 'title': "Lit " + rOrRho,
'type': "natural-minus-na",
'width': "40px",
'data': "lit_corr",
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Tissue {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}",
+ 'title': "Tissue " + rOrRho,
'type': "natural-minus-na",
'width': "40px",
'data': "tissue_corr",
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Tissue p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})",
+ 'title': "Tissue p(" + rOrRho + ")",
'type': "natural-minus-na",
'width': "40px",
'data': "tissue_pvalue",
@@ -411,14 +419,14 @@
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}",
+ 'title': "Sample " + rOrRho,
'type': "natural-minus-na",
'width': "40px",
'data': null,
'orderSequence': [ "desc", "asc"],
'render': function(data) {
if (data.sample_r != "N/A") {
- return "" + data.sample_r + ""
+ return "" + data.sample_r + ""
} else {
return data.sample_r
}
@@ -432,7 +440,7 @@
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})",
+ 'title': "Sample p(" + rOrRho + ")",
'type': "scientific",
'width': "65px",
'data': "sample_p",
@@ -465,14 +473,14 @@
'data': "location"
},
{
- 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}",
+ 'title': "Sample " + rOrRho,
'type': "natural-minus-na",
'width': "40px",
'data': null,
'orderSequence': [ "desc", "asc"],
'render': function(data) {
if (data.sample_r != "N/A") {
- return "" + data.sample_r + ""
+ return "" + data.sample_r + ""
} else {
return data.sample_r
}
@@ -486,7 +494,7 @@
'orderSequence': [ "desc", "asc"]
},
{
- 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})",
+ 'title': "Sample p(" + rOrRho + ")",
'type': "scientific",
'width': "65px",
'data': "sample_p",
--
cgit v1.2.3