diff options
-rw-r--r-- | wqflask/wqflask/correlation/corr_scatter_plot.py | 21 | ||||
-rw-r--r-- | wqflask/wqflask/templates/mapping_results.html | 2 |
2 files changed, 14 insertions, 9 deletions
diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py index 5df28c45..e5f545a2 100644 --- a/wqflask/wqflask/correlation/corr_scatter_plot.py +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -1,9 +1,13 @@ +import json import math +from redis import Redis +Redis = Redis() + from flask import g from base.trait import create_trait, retrieve_sample_data -from base import data_set +from base import data_set, webqtlCaseData from utility import corr_result_helpers from scipy import stats import numpy as np @@ -39,13 +43,14 @@ class CorrScatterPlot: if self.dataset_1.group.f1list != None: primary_samples += self.dataset_1.group.f1list - self.trait_1 = retrieve_sample_data( - self.trait_1, self.dataset_1, primary_samples) - self.trait_2 = retrieve_sample_data( - self.trait_2, self.dataset_2, primary_samples) - - samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples( - self.trait_1.data, self.trait_2.data) + 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"} + samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples( + self.trait_1.data, trait_data) + else: + samples_1, samples_2, num_overlap = corr_result_helpers.normalize_values_with_samples( + self.trait_1.data, self.trait_2.data) self.data = [] self.indIDs = list(samples_1.keys()) diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html index e77bbad3..b1e1b5c8 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.group.name }}Geno&dataset_2={{ dataset.name }}&trait_1=' + data.name + '&trait_2={{ this_trait.name }}">' + 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 }}&dataid={{ dataid }}">' + String(parseFloat(data.additive).toFixed(3)) + '</a>' {% else %} return String(parseFloat(data.additive).toFixed(3)) {% endif %} |