aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2023-10-03 19:56:24 +0000
committerzsloan2023-10-03 19:56:24 +0000
commit0244237f49db76724fab9511eb07d6641dcdc3c7 (patch)
tree103650e76c277bfab0e647472f1c17144b8861c9
parentb4001d74419eb4aa05e9782776d8210faa218575 (diff)
downloadgenenetwork2-0244237f49db76724fab9511eb07d6641dcdc3c7.tar.gz
Include cached_trait parameter for scatterplot, so it knows which trait to use the cached data for
-rw-r--r--wqflask/wqflask/correlation/corr_scatter_plot.py13
-rw-r--r--wqflask/wqflask/templates/mapping_results.html2
2 files changed, 11 insertions, 4 deletions
diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py
index 13d1f240..16e36f9d 100644
--- a/wqflask/wqflask/correlation/corr_scatter_plot.py
+++ b/wqflask/wqflask/correlation/corr_scatter_plot.py
@@ -12,6 +12,8 @@ from wqflask.oauth2.collections import num_collections
from scipy import stats
import numpy as np
+import logging
+logger = logging.getLogger(__name__)
class CorrScatterPlot:
"""Page that displays a correlation scatterplot with a line fitted to it"""
@@ -28,12 +30,10 @@ class CorrScatterPlot:
else:
self.dataset_2 = data_set.create_dataset(params['dataset_2'])
- #self.dataset_3 = data_set.create_dataset(params['dataset_3'])
self.trait_1 = create_trait(
name=params['trait_1'], dataset=self.dataset_1)
self.trait_2 = create_trait(
name=params['trait_2'], dataset=self.dataset_2)
- #self.trait_3 = create_trait(name=params['trait_3'], dataset=self.dataset_3)
self.method = params['method']
@@ -46,8 +46,15 @@ class CorrScatterPlot:
if 'dataid' in params:
trait_data_dict = json.loads(Redis.get(params['dataid']))
trait_data = {key:webqtlCaseData.webqtlCaseData(key, float(trait_data_dict[key])) for (key, value) in trait_data_dict.items() if trait_data_dict[key] != "x"}
+ trait_1_data = trait_data
+ trait_2_data = self.trait_2.data
+ # Check if the cached data should be used for the second trait instead
+ if 'cached_trait' in params:
+ if params['cached_trait'] == 'trait_2':
+ trait_2_data = trait_data
+ trait_1_data = self.trait_1.data
samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples(
- trait_data, self.trait_2.data)
+ trait_1_data, trait_2_data)
else:
samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples(
self.trait_1.data, self.trait_2.data)
diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html
index 81101fed..61ec66d0 100644
--- a/wqflask/wqflask/templates/mapping_results.html
+++ b/wqflask/wqflask/templates/mapping_results.html
@@ -420,7 +420,7 @@
'data': null,
'render': function(data, type, row, meta) {
{% if geno_db_exists == "True" %}
- return '<a target"_blank" href="corr_scatter_plot?method=pearson&dataset_1={{ dataset.name }}&dataset_2={{ dataset.group.name }}Geno&trait_1={{ this_trait.name }}&trait_2=' + data.name + '&dataid={{ dataid }}">' + String(parseFloat(data.additive).toFixed(3)) + '</a>'
+ return '<a target"_blank" href="corr_scatter_plot?method=pearson&dataset_1={{ dataset.group.name }}Geno&dataset_2={{ dataset.name }}&trait_1=' + data.name + '&trait_2={{ this_trait.name }}&cached_trait=trait_2&dataid={{ dataid }}">' + String(parseFloat(data.additive).toFixed(3)) + '</a>'
{% else %}
return String(parseFloat(data.additive).toFixed(3))
{% endif %}