aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/wqflask/correlation_matrix/show_corr_matrix.py61
-rw-r--r--wqflask/wqflask/heatmap/__init__.py0
-rw-r--r--wqflask/wqflask/heatmap/heatmap.py91
-rwxr-xr-xwqflask/wqflask/templates/collections/view.html12
-rwxr-xr-xwqflask/wqflask/views.py11
5 files changed, 112 insertions, 63 deletions
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index 4069b07f..85bc7fd5 100755
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -64,66 +64,7 @@ class CorrelationMatrix(object):
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
- self.get_trait_db_obs(trait_db_list)
-
- #self.corr_results = {}
- #for trait_db in self.trait_list:
- # this_trait = trait_db[0]
- # this_db = trait_db[1]
- #
- # this_db_samples = this_db.group.samplelist
- # this_sample_data = this_trait.data
- # print("this_sample_data", len(this_sample_data))
- #
- # corr_result_row = {}
- #
- # for target in self.trait_list:
- # target_trait = target[0]
- # target_db = target[1]
- # target_samples = target_db.group.samplelist
- #
- # if this_trait == target_trait and this_db == target_db:
- # corr_result_row[this_trait.name] = {'sample_r': 1,
- # 'sample_p': 0,
- # 'num_overlap': len(target_samples),
- # 'this_trait': this_trait.name,
- # 'this_db': this_trait.dataset.name,
- # 'target_trait': this_trait.name,
- # 'target_db': this_trait.dataset.name}
- # continue
- #
- # target_sample_data = target_trait.data
- # print("target_samples", len(target_samples))
- #
- # this_trait_vals = []
- # target_vals = []
- # for index, sample in enumerate(target_samples):
- #
- # if (sample in this_sample_data) and (sample in target_sample_data):
- # sample_value = this_sample_data[sample].value
- # target_sample_value = target_sample_data[sample].value
- # this_trait_vals.append(sample_value)
- # target_vals.append(target_sample_value)
- #
- # #print("this_trait_vals:", this_trait_vals)
- # #print("target_vals:", target_vals)
- #
- # this_trait_vals, target_vals, num_overlap = corr_result_helpers.normalize_values(
- # this_trait_vals, target_vals)
- #
- # sample_r, sample_p = scipy.stats.pearsonr(this_trait_vals, target_vals)
- #
- # corr_matrix_cell = {"sample_r": sample_r,
- # "sample_p": sample_p,
- # "num_overlap": num_overlap,
- # "this_trait": this_trait.name,
- # "this_db": this_trait.dataset.name,
- # "target_trait": target_trait.name,
- # "target_db": target_trait.dataset.name}
- #
- # corr_result_row[target_trait.name] = corr_matrix_cell
- #
- # self.corr_results[this_trait.name] = corr_result_row
+ helper_functions.get_trait_db_obs(trait_db_list)
self.all_sample_list = []
self.traits = []
diff --git a/wqflask/wqflask/heatmap/__init__.py b/wqflask/wqflask/heatmap/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/wqflask/wqflask/heatmap/__init__.py
diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py
index 3ee33184..d9c02381 100644
--- a/wqflask/wqflask/heatmap/heatmap.py
+++ b/wqflask/wqflask/heatmap/heatmap.py
@@ -1,9 +1,94 @@
from __future__ import absolute_import, print_function, division
-class HeatMapobject):
+import sys
+sys.path.append(".")
+
+import gc
+import string
+import cPickle
+import os
+import time
+import pp
+import math
+import collections
+import resource
+
+import scipy
+
+from pprint import pformat as pf
+
+from htmlgen import HTMLgen2 as HT
+import reaper
+
+from base import webqtlConfig
+from utility.THCell import THCell
+from utility.TDCell import TDCell
+from base.trait import GeneralTrait
+from base import data_set
+from base.templatePage import templatePage
+from utility import webqtlUtil, helper_functions, corr_result_helpers
+from dbFunction import webqtlDatabaseFunction
+import utility.webqtlUtil #this is for parallel computing only.
+from wqflask.correlation import correlation_functions
+from utility.benchmark import Bench
+
+from MySQLdb import escape_string as escape
+
+from pprint import pformat as pf
+
+from flask import Flask, g
+
+class Heatmap(object):
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
- helper_functions.get_trait_db_obs(trait_db_list)
- \ No newline at end of file
+
+ helper_functions.get_trait_db_obs(self, trait_db_list)
+
+ self.all_sample_list = []
+ self.traits = []
+ for trait_db in self.trait_list:
+ this_trait = trait_db[0]
+ self.traits.append(this_trait.name)
+ this_sample_data = this_trait.data
+
+ for sample in this_sample_data:
+ if sample not in self.all_sample_list:
+ self.all_sample_list.append(sample)
+
+ self.sample_data = []
+ for trait_db in self.trait_list:
+ this_trait = trait_db[0]
+ this_sample_data = this_trait.data
+
+ #self.sample_data[this_trait.name] = []
+ this_trait_vals = []
+ for sample in self.all_sample_list:
+ if sample in this_sample_data:
+ this_trait_vals.append(this_sample_data[sample].value)
+ #self.sample_data[this_trait.name].append(this_sample_data[sample].value)
+ else:
+ this_trait_vals.append('')
+ #self.sample_data[this_trait.name].append('')
+ self.sample_data.append(this_trait_vals)
+
+ self.trait_results = {}
+ for trait_db in self.trait_list:
+ this_trait = trait_db[0]
+ this_db = trait_db[1]
+
+ this_db_samples = this_db.group.samplelist
+ this_sample_data = this_trait.data
+ print("this_sample_data", this_sample_data)
+ this_trait_vals = []
+ for index, sample in enumerate(target_samples):
+
+ if (sample in this_sample_data) and (sample in target_sample_data):
+ sample_value = this_sample_data[sample].value
+ target_sample_value = target_sample_data[sample].value
+ this_trait_vals.append(sample_value)
+ target_vals.append(target_sample_value)
+
+
+ \ No newline at end of file
diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html
index 2f6c5188..eee22afe 100755
--- a/wqflask/wqflask/templates/collections/view.html
+++ b/wqflask/wqflask/templates/collections/view.html
@@ -36,6 +36,18 @@
class="btn btn-small"
value="Correlation Matrix" />
</form>
+ <form action="/heatmap" method="post">
+ {% if uc %}
+ <input type="hidden" name="uc_id" id="uc_id" value="{{ uc.id }}" />
+ {% endif %}
+ <input type="hidden" name="trait_list" id="trait_list" value= "
+ {% for this_trait in trait_obs %}
+ {{ this_trait.name }}:{{ this_trait.dataset.name }},
+ {% endfor %}" >
+ <input type="submit"
+ class="btn btn-small"
+ value="Heatmap" />
+ </form>
</div>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 47a18149..e65da914 100755
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -32,6 +32,7 @@ from base.data_set import DataSet # Used by YAML in marker_regression
from base.data_set import create_datasets_list
from wqflask.show_trait import show_trait
from wqflask.show_trait import export_trait_data
+from wqflask.heatmap import heatmap
from wqflask.marker_regression import marker_regression
from wqflask.interval_mapping import interval_mapping
from wqflask.correlation import show_corr_results
@@ -352,6 +353,16 @@ def corr_matrix_page():
return render_template("correlation_matrix.html", **template_vars.__dict__)
+@app.route("/heatmap", methods=('POST',))
+def heatmap_page():
+ print("In heatmap, request.form is:", pf(request.form))
+ template_vars = heatmap.Heatmap(request.form)
+ template_vars.js_data = json.dumps(template_vars.js_data,
+ default=json_default_handler,
+ indent=" ")
+
+ return render_template("heatmap.html", **template_vars.__dict__)
+
@app.route("/corr_scatter_plot")
def corr_scatter_plot_page():
template_vars = corr_scatter_plot.CorrScatterPlot(request.args)