aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorPjotr Prins2016-04-29 08:18:39 +0000
committerPjotr Prins2016-04-29 08:18:39 +0000
commit1d50581402b368dd55f29135cca643b357b5a65b (patch)
tree7736db1d4fb14ee9ad97de95a71932a96738e3cb /wqflask
parent6e23be8f278e98386171f4702414224545decfe0 (diff)
parent6e6482db14c3840328d786c551feea6e34a3ef06 (diff)
downloadgenenetwork2-1d50581402b368dd55f29135cca643b357b5a65b.tar.gz
Merge
Diffstat (limited to 'wqflask')
-rw-r--r--[-rwxr-xr-x]wqflask/base/data_set.py5
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression.py12
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py1
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js4
-rw-r--r--wqflask/wqflask/templates/marker_regression_gn1.html31
-rwxr-xr-xwqflask/wqflask/templates/show_trait.html1
-rwxr-xr-xwqflask/wqflask/templates/show_trait_statistics.html2
-rw-r--r--wqflask/wqflask/views.py23
8 files changed, 68 insertions, 11 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 52ac95f0..053b45fc 100755..100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -417,6 +417,7 @@ class DataSet(object):
self.shortname = None
self.fullname = None
self.type = None
+ self.data_scale = None #ZS: For example log2
self.setup()
@@ -456,8 +457,8 @@ class DataSet(object):
self.name,
self.name))
- self.id, self.name, self.fullname, self.shortname, self.tissue = g.db.execute("""
- SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, Tissue.Name
+ self.id, self.name, self.fullname, self.shortname, self.data_scale, self.tissue = g.db.execute("""
+ SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, ProbeSetFreeze.DataScale, Tissue.Name
FROM ProbeSetFreeze, ProbeFreeze, Tissue
WHERE ProbeSetFreeze.public > %s AND
ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index b56b179b..08f422f0 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -74,6 +74,8 @@ class MarkerRegression(object):
self.pair_scan = False # Initializing this since it is checked in views to determine which template to use
self.score_type = "LRS" #ZS: LRS or LOD
self.mapping_scale = "physic"
+ self.num_perm = 0
+ self.perm_output = []
self.bootstrap_results = []
#ZS: This is passed to GN1 code for single chr mapping
@@ -120,13 +122,14 @@ class MarkerRegression(object):
try:
if int(start_vars['num_perm']) > 0:
self.num_perm = int(start_vars['num_perm'])
- else:
- self.num_perm = 0
except:
self.num_perm = 0
self.LRSCheck = self.score_type
- self.permCheck = "ON"
+ if self.num_perm > 0:
+ self.permCheck = "ON"
+ else:
+ self.permCheck = False
self.showSNP = "ON"
self.showGenes = "ON"
self.viewLegend = "ON"
@@ -273,6 +276,8 @@ class MarkerRegression(object):
mapping_scale = self.mapping_scale,
chromosomes = chromosome_mb_lengths,
qtl_results = self.qtl_results,
+ num_perm = self.num_perm,
+ perm_results = self.perm_output,
)
@@ -652,6 +657,7 @@ class MarkerRegression(object):
self.perm_output = genotype.permutation(strains = trimmed_samples, trait = trimmed_values, nperm=self.num_perm)
self.suggestive = self.perm_output[int(self.num_perm*0.37-1)]
self.significant = self.perm_output[int(self.num_perm*0.95-1)]
+ self.highly_significant = self.perm_output[int(self.num_perm*0.99-1)]
self.json_data['suggestive'] = self.suggestive
self.json_data['significant'] = self.significant
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 79f1c867..074c78bf 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -150,6 +150,7 @@ class ShowTrait(object):
self.trait_table_width = get_trait_table_width(self.sample_groups)
js_data = dict(dataset_type = self.dataset.type,
+ data_scale = self.dataset.data_scale,
sample_group_types = self.sample_group_types,
sample_lists = sample_lists,
attribute_names = self.sample_groups[0].attributes,
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 9d418e9b..9e249c28 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -190,9 +190,9 @@
}
row_line = "<tr>";
if (row.url != null) {
- row_line += "<td id=\"" + row.vn + "\" style=\"border-right: 1px solid #000000;\"><a href=\"" + row.url + "\">" + row.pretty + "</a></td>";
+ row_line += "<td id=\"" + row.vn + "\"><a href=\"" + row.url + "\">" + row.pretty + "</a></td>";
} else {
- row_line += "<td id=\"" + row.vn + "\" style=\"border-right: 1px solid #000000;\">" + row.pretty + "</td>";
+ row_line += "<td id=\"" + row.vn + "\">" + row.pretty + "</td>";
}
_ref1 = js_data.sample_group_types;
for (key in _ref1) {
diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html
index 07f764ca..df948190 100644
--- a/wqflask/wqflask/templates/marker_regression_gn1.html
+++ b/wqflask/wqflask/templates/marker_regression_gn1.html
@@ -22,6 +22,7 @@
<input type="hidden" name="selected_chr" value="{{ selectedChr }}">
<input type="hidden" name="manhattan_plot" value="{{ manhattan_plot }}">
<input type="hidden" name="num_perm" value="{{ nperm }}">
+ <input type="hidden" name="perm_results" value="">
<input type="hidden" name="num_bootstrap" value="{{ nboot }}">
<input type="hidden" name="do_control" value="{{ doControl }}">
<input type="hidden" name="control_marker" value="{{ controlLocus }}">
@@ -148,9 +149,12 @@
<br>
<span style="white-space: nowrap;">A positive additive coefficient (green line) indicates that {{ dataset.group.parlist[1] }} alleles increase trait values. In contrast, a negative additive coefficient (orange line) indicates that {{ dataset.group.parlist[0] }} alleles increase trait values.</span>
{% endif %}
- {% if nperm > 0 %}
+ {% if nperm > 0 and permChecked == "ON" %}
<br><br>
<img src="/static/output/{{ perm_filename }}.gif">
+ <br><br>
+ Total of {{ nperm }} permutations&nbsp;&nbsp;<a href="javascript:export_perm_data();" target="_blank" >Download Permutation Results</a>
+ <br>
{% endif %}
</div>
</div>
@@ -292,7 +296,20 @@
"scrollCollapse": true,
"paging": false
} );
- console.timeEnd("Creating table");
+
+ $('#interval_analyst').dataTable( {
+ "columnDefs": [ {
+ "targets": 0,
+ "sortable": false
+ }],
+ "order": [[3, "asc"]],
+ "sDom": "RZtir",
+ "iDisplayLength": -1,
+ "autoWidth": true,
+ "bDeferRender": true,
+ "bSortClasses": false,
+ "paging": false
+ } );
$('#vector_map_tab').click(function(){
$('div#gn1_map_options').hide();
@@ -325,6 +342,16 @@
return $('#marker_regression_form').submit();
};
+ export_perm_data = function() {
+ var num_perm, perm_data;
+ num_perm = js_data.num_perm
+ perm_data = js_data.perm_results
+ json_perm_data = JSON.stringify(perm_data);
+ $('input[name=perm_results]').val(json_perm_data);
+ $('#marker_regression_form').attr('action', '/export_perm_data');
+ return $('#marker_regression_form').submit();
+ };
+
</script>
{% endblock %}
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 7429cd5f..64638fc7 100755
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -254,7 +254,6 @@
} );
{% endif %}
- console.log("SAMPLE GROUP TYPES:", js_data.sample_group_types)
if (Object.keys(js_data.sample_group_types).length > 1) {
$('#stats_table').DataTable( {
"columnDefs": [
diff --git a/wqflask/wqflask/templates/show_trait_statistics.html b/wqflask/wqflask/templates/show_trait_statistics.html
index 9a57b285..242f1c26 100755
--- a/wqflask/wqflask/templates/show_trait_statistics.html
+++ b/wqflask/wqflask/templates/show_trait_statistics.html
@@ -26,7 +26,7 @@
<div class="tab-content">
<div class="tab-pane active" id="stats_tab">
<div style="padding: 20px" class="form-horizontal">
- <table id="stats_table" style="width: 300px; float: left;" class="table table-hover table-striped cell-border"></table>
+ <table border="1" id="stats_table" style="width: 300px; float: left;" class="table table-hover table-striped cell-border"></table>
</div>
</div>
<div class="tab-pane" id="histogram_tab">
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 87ba8b32..bd2fff50 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -284,6 +284,29 @@ def export_trait_csv():
return Response(csv_data,
mimetype='text/csv',
headers={"Content-Disposition":"attachment;filename=sample_data.csv"})
+
+@app.route('/export_perm_data', methods=('POST',))
+def export_perm_data():
+ """CSV file consisting of the permutation data for the mapping results"""
+ num_perm = float(request.form['num_perm'])
+ perm_data = json.loads(request.form['perm_results'])
+
+ buff = StringIO.StringIO()
+ writer = csv.writer(buff)
+ writer.writerow(["Suggestive LRS (p=0.63) = " + str(perm_data[int(num_perm*0.37-1)])])
+ writer.writerow(["Significant LRS (p=0.05) = " + str(perm_data[int(num_perm*0.95-1)])])
+ writer.writerow(["Highly Significant LRS (p=0.01) = " + str(perm_data[int(num_perm*0.99-1)])])
+ writer.writerow("")
+ writer.writerow([str(num_perm) + " Permutations"])
+ writer.writerow("")
+ for item in perm_data:
+ writer.writerow([item])
+ csv_data = buff.getvalue()
+ buff.close()
+
+ return Response(csv_data,
+ mimetype='text/csv',
+ headers={"Content-Disposition":"attachment;filename=perm_data.csv"})
@app.route("/show_trait")
def show_trait_page():