aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py63
-rw-r--r--wqflask/wqflask/static/dbdoc/TODO.md1
-rw-r--r--wqflask/wqflask/templates/correlation_page.html65
-rw-r--r--wqflask/wqflask/templates/empty_collection.html2
-rw-r--r--wqflask/wqflask/views.py2
5 files changed, 115 insertions, 18 deletions
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index 4d7fea61..9b048346 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -32,6 +32,7 @@ import pp
import math
import collections
import resource
+import json
import scipy
@@ -51,6 +52,7 @@ import utility.webqtlUtil #this is for parallel computing only.
from wqflask.correlation import correlation_functions
from utility.benchmark import Bench
import utility.webqtlUtil
+from wqflask import user_manager
from MySQLdb import escape_string as escape
@@ -248,7 +250,7 @@ class CorrelationResults(object):
else:
self.this_trait_vals.append("None")
num_overlap = len(self.this_trait_vals)
-
+ logger.debug("DOING PARALLEL")
self.do_parallel_correlation(db_filename, num_overlap)
else:
for trait, values in self.target_dataset.trait_data.iteritems():
@@ -335,6 +337,7 @@ class CorrelationResults(object):
#print("self.correlation_results: ", pf(self.correlation_results))
+ self.json_results = generate_corr_json(self.correlation_results, self.this_trait, self.dataset, self.target_dataset)
#XZ, 09/18/2008: get all information about the user selected database.
#target_db_name = fd.corr_dataset
@@ -1431,3 +1434,61 @@ class CorrelationResults(object):
# for one_result in results:
# for one_traitinfo in one_result:
# allcorrelations.append( one_traitinfo )
+
+def generate_corr_json(corr_results, this_trait, dataset, target_dataset):
+ results_list = []
+ for i, trait in enumerate(corr_results):
+ results_dict = {}
+ results_dict['checkbox'] = "<INPUT TYPE='checkbox' NAME='searchResult' class='checkbox trait_checkbox' style='padding-right: 0px;' VALUE='" + user_manager.data_hmac('{}:{}'.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>"
+ if target_dataset.type == "ProbeSet":
+ results_dict['symbol'] = trait.symbol
+ results_dict['description'] = trait.description_display
+ results_dict['location'] = trait.location_repr
+ 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_location'] = trait.LRS_location_repr
+ if trait.additive != "":
+ results_dict['additive'] = "%0.3f" % float(trait.additive)
+ else:
+ results_dict['additive'] = "N/A"
+ 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['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)
+ elif target_dataset.type == "Publish":
+ results_dict['description'] = trait.description_display
+ results_dict['authors'] = trait.authors
+ if trait.pubmed_id:
+ results_dict['pubmed'] = "<a href='" + trait.pubmed_link + "'> " + trait.pubmed_text + "</a>"
+ else:
+ results_dict['pubmed'] = "N/A"
+ 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"
+ 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>"
+ results_dict['num_overlap'] = trait.num_overlap
+ results_dict['sample_p'] = "%0.3e" % float(trait.sample_p)
+ else:
+ results_dict['lrs_location'] = trait.LRS_location_repr
+ 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['num_overlap'] = trait.num_overlap
+ results_dict['sample_p'] = "%0.3e" % float(trait.sample_p)
+
+ results_list.append(results_dict)
+
+ return json.dumps(results_list)
diff --git a/wqflask/wqflask/static/dbdoc/TODO.md b/wqflask/wqflask/static/dbdoc/TODO.md
new file mode 100644
index 00000000..c0a8bab7
--- /dev/null
+++ b/wqflask/wqflask/static/dbdoc/TODO.md
@@ -0,0 +1 @@
+TODO: Add all database documentation into this folder
diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html
index 629724c0..1254ea6a 100644
--- a/wqflask/wqflask/templates/correlation_page.html
+++ b/wqflask/wqflask/templates/correlation_page.html
@@ -65,8 +65,10 @@
<div style="width: {% if target_dataset.type == "ProbeSet" %}1600px{% elif target_dataset.type == "Publish" %}1400px{% else %}800px{% endif %};">
<table id="trait_table" class="display dataTable nowrap" style="font-size: 12px; float: left;">
+<!--
<thead>
<tr>
+ <th></th>
{% for header in target_dataset.header_fields %}
{% if header == 'Year' %}
<th>{{header}}</th>
@@ -129,7 +131,8 @@
<tbody>
{% for trait in correlation_results %}
<tr>
- <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center; display: inline;">{{ loop.index }}<INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td>
+ <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 style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center; display: inline;">{{ loop.index }}</td>
<td>
<a href="{{ url_for('show_trait_page',
trait_id = trait.name,
@@ -182,6 +185,7 @@
</tr>
{% endfor %}
</tbody>
+-->
</table>
</div>
</div>
@@ -267,24 +271,55 @@
$(document).ready( function () {
+ var table_json = {{ json_results | safe }}
+
+
+ {% if target_dataset.type == "ProbeSet" %}
+ var json_array = new Array();
+
+ for (i=0; i < table_json.length; i++){
+ json_array.push({
+ checkbox: table_json[i]["checkbox"],
+ index: table_json[i]["index"],
+ trait_id: table_json[i]["trait_id"],
+ symbol: table_json[i]["symbol"],
+ description: table_json[i]["description"],
+ location: table_json[i]["location"],
+ mean: table_json[i]["mean"],
+ lrs_score: table_json[i]["lrs_score"],
+ lrs_location: table_json[i]["lrs_location"],
+ additive: table_json[i]["additive"],
+ sample_r: table_json[i]["sample_r"],
+ num_overlap: table_json[i]["num_overlap"],
+ sample_p: table_json[i]["sample_p"],
+ lit_corr: table_json[i]["lit_corr"],
+ tissue_corr: table_json[i]["tissue_corr"]
+ });
+ console.log("JSON_DATA:", json_array);
+ }
+ //console.log("JSON_DATA:", json_array)
+
$("#trait_table").tabulator({
+ data: json_array,
columns:[
- {title:"Index", formatter:"html"},
- {title:"Record", formatter:"html"},
- {title:"Symbol", formatter:"plaintext"},
- {title:"Description", formatter:"textarea", width:"25%"},
- {title:"Location", formatter:"plaintext"},
- {title:"Mean", formatter:"plaintext"},
- {title:"Max LRS", formatter:"plaintext"},
- {title:"Max LRS Location", formatter:"plaintext"},
- {title:"Additive Effect", formatter:"plaintext"},
- {title:"Sample r", formatter:"html"},
- {title:"N", formatter:"plaintext"},
- {title:"Sample p(r)", formatter:"plaintext"},
- {title:"Lit r", formatter:"plaintext"},
- {title:"Tissue r", formatter:"plaintext"}
+ {title:"", field:"checkbox", formatter:"html"},
+ {title:"Index", field:"index", formatter:"plaintext"},
+ {title:"Record", field:"trait_id", formatter:"html"},
+ {title:"Symbol", field:"symbol", formatter:"plaintext"},
+ {title:"Description", field:"description", formatter:"textarea", width:"25%"},
+ {title:"Location", field:"location", formatter:"plaintext"},
+ {title:"Mean", field:"mean", formatter:"plaintext"},
+ {title:"Max LRS", field:"lrs_score", formatter:"plaintext"},
+ {title:"Max LRS Location", field:"lrs_location", formatter:"plaintext"},
+ {title:"Additive Effect", field:"additive", formatter:"plaintext"},
+ {title:"Sample r", field:"sample_r", formatter:"html"},
+ {title:"N", field:"num_overlap", formatter:"plaintext"},
+ {title:"Sample p(r)", field:"sample_p", formatter:"plaintext"},
+ {title:"Lit r", field:"lit_corr", formatter:"plaintext"},
+ {title:"Tissue r", field:"tissue_corr", formatter:"plaintext"}
]
});
+ {% endif %}
$('#trait_table tr').click(function(event) {
if (event.target.type !== 'checkbox') {
diff --git a/wqflask/wqflask/templates/empty_collection.html b/wqflask/wqflask/templates/empty_collection.html
index 3f2b3786..d1b779ef 100644
--- a/wqflask/wqflask/templates/empty_collection.html
+++ b/wqflask/wqflask/templates/empty_collection.html
@@ -6,7 +6,7 @@
<div class="container">
<input type="hidden" name="uc_id" id="uc_id" value="{{ uc_id }}">
- <p>You must select at least one trait to use the {{ tool }}.</p>
+ <p>You must select at least two traits to use the {{ tool }}.</p>
</div>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 4e81c29c..187b60dc 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -743,7 +743,7 @@ def corr_matrix_page():
start_vars = request.form
traits = [trait.strip() for trait in start_vars['trait_list'].split(',')]
- if traits[0] != "":
+ if len(traits) > 1:
template_vars = show_corr_matrix.CorrelationMatrix(start_vars)
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,