aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2016-03-18 15:57:18 +0000
committerzsloan2016-03-18 15:57:18 +0000
commitd4cf1581d13dcf2ba68d33f7fde48392e1c5a063 (patch)
treed0a5eb45968cac4fb741888dfc6f42307ece9223 /wqflask
parentc64e7f8e6742ff37e6d9446c825492264d531858 (diff)
parente1b62e892ef132296429b1f6197686e4866ab648 (diff)
downloadgenenetwork2-d4cf1581d13dcf2ba68d33f7fde48392e1c5a063.tar.gz
Merge branch 'development' of github.com:genenetwork/genenetwork2
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/data_set.py9
-rwxr-xr-xwqflask/base/trait.py2
-rwxr-xr-xwqflask/wqflask/gsearch.py2
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression_gn1.py7
-rw-r--r--wqflask/wqflask/static/new/javascript/create_lodchart.coffee4
-rw-r--r--wqflask/wqflask/static/new/javascript/create_lodchart.js87
-rw-r--r--wqflask/wqflask/templates/marker_regression_gn1.html110
-rwxr-xr-xwqflask/wqflask/views.py11
8 files changed, 163 insertions, 69 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 6cabadb1..e37a838f 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -54,7 +54,7 @@ from pprint import pformat as pf
# Each subclass will add to this
DS_NAME_MAP = {}
-def create_dataset(dataset_name, dataset_type = None):
+def create_dataset(dataset_name, dataset_type = None, get_samplelist = True):
if not dataset_type:
dataset_type = Dataset_Getter(dataset_name)
#dataset_type = get_dataset_type_from_json(dataset_name)
@@ -71,7 +71,7 @@ def create_dataset(dataset_name, dataset_type = None):
dataset_ob = DS_NAME_MAP[dataset_type]
dataset_class = globals()[dataset_ob]
- return dataset_class(dataset_name)
+ return dataset_class(dataset_name, get_samplelist)
#def get_dataset_type_from_json(dataset_name):
@@ -501,7 +501,7 @@ class DataSet(object):
"""
- def __init__(self, name):
+ def __init__(self, name, get_samplelist = True):
assert name, "Need a name"
self.name = name
@@ -517,7 +517,8 @@ class DataSet(object):
self.retrieve_other_names()
self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype
- self.group.get_samplelist()
+ if get_samplelist == True:
+ self.group.get_samplelist()
self.species = species.TheSpecies(self)
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index ff149ba3..acff38d9 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -67,7 +67,7 @@ class GeneralTrait(object):
# Todo: These two lines are necessary most of the time, but perhaps not all of the time
# So we could add a simple if statement to short-circuit this if necessary
self.retrieve_info(get_qtl_info=get_qtl_info)
- if kw.get('get_sample_info') != False:
+ if get_sample_info != False:
self.retrieve_sample_data()
diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py
index a6efb47f..4179dc48 100755
--- a/wqflask/wqflask/gsearch.py
+++ b/wqflask/wqflask/gsearch.py
@@ -46,7 +46,7 @@ class GSearch(object):
self.trait_list = []
with Bench("Creating trait objects"):
for line in re:
- dataset = create_dataset(line[3], "ProbeSet")
+ dataset = create_dataset(line[3], "ProbeSet", get_samplelist=False)
trait_id = line[4]
#with Bench("Building trait object"):
this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=True, get_sample_info=False)
diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
index 56286ee6..e9052290 100644
--- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py
+++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
@@ -295,10 +295,13 @@ class MarkerRegression(object):
self.SNPChecked = False
self.draw2X = False
self.lrsMax = 0
- if 'mb_range' in start_vars:
- self.startMb, self.endMb = [float(x) for x in start_vars['mb_range'].split(',')]
+ if 'startMb' in start_vars:
+ self.startMb = start_vars['startMb']
else:
self.startMb = -1
+ if 'endMb' in start_vars:
+ self.endMb = start_vars['endMb']
+ else:
self.endMb = -1
#self.additiveChecked = fd.formdata.getvalue('additiveCheck')
diff --git a/wqflask/wqflask/static/new/javascript/create_lodchart.coffee b/wqflask/wqflask/static/new/javascript/create_lodchart.coffee
index 472ec12d..88003f4e 100644
--- a/wqflask/wqflask/static/new/javascript/create_lodchart.coffee
+++ b/wqflask/wqflask/static/new/javascript/create_lodchart.coffee
@@ -46,9 +46,5 @@ create_lod_chart = ->
.transition().duration(500).attr("r", r)
$ ->
- #window.setTimeout ( ->
- # console.log(js_data)
- #), 1000
- #window.setTimeout(create_lod_chart(), 1000)
root.create_lod_chart = create_lod_chart
diff --git a/wqflask/wqflask/static/new/javascript/create_lodchart.js b/wqflask/wqflask/static/new/javascript/create_lodchart.js
index c756d842..778eed3a 100644
--- a/wqflask/wqflask/static/new/javascript/create_lodchart.js
+++ b/wqflask/wqflask/static/new/javascript/create_lodchart.js
@@ -1,45 +1,50 @@
-// Generated by CoffeeScript 1.9.2
-(function() {
- var create_lod_chart;
+//var create_lod_chart;
- create_lod_chart = function() {
- var chrrect, data, h, halfh, margin, mychart, totalh, totalw, w;
- h = 500;
- w = 1200;
- margin = {
- left: 60,
- top: 40,
- right: 40,
- bottom: 40,
- inner: 5
- };
- halfh = h + margin.top + margin.bottom;
- totalh = halfh * 2;
- totalw = w + margin.left + margin.right;
- console.log("js_data:", js_data);
- mychart = lodchart().lodvarname("lod.hk").height(h).width(w).margin(margin).ylab(js_data.result_score_type + " score").mappingScale(js_data.mapping_scale).manhattanPlot(js_data.manhattan_plot);
- data = js_data.json_data;
- d3.select("div#topchart").datum(data).call(mychart);
- chrrect = mychart.chrSelect();
- chrrect.on("mouseover", function() {
- return d3.select(this).attr("fill", "#E9CFEC");
- }).on("mouseout", function(d, i) {
- return d3.select(this).attr("fill", function() {
- if (i % 2) {
- return "#F1F1F9";
- }
- return "#FBFBFF";
- });
- });
- return mychart.markerSelect().on("click", function(d) {
- var r;
- r = d3.select(this).attr("r");
- return d3.select(this).transition().duration(500).attr("r", r * 3).transition().duration(500).attr("r", r);
- });
+create_lod_chart = function() {
+ var additive, chrrect, data, h, halfh, margin, mychart, totalh, totalw, w;
+ h = 500;
+ w = 1200;
+ margin = {
+ left: 60,
+ top: 40,
+ right: 40,
+ bottom: 40,
+ inner: 5
};
-
- $(function() {
- return root.create_lod_chart = create_lod_chart;
+ halfh = h + margin.top + margin.bottom;
+ totalh = halfh * 2;
+ totalw = w + margin.left + margin.right;
+ if ('additive' in js_data) {
+ additive = js_data.additive;
+ } else {
+ additive = false;
+ }
+ console.log("js_data:", js_data);
+ mychart = lodchart().lodvarname("lod.hk").height(h).width(w).margin(margin).ylab(js_data.result_score_type + " score").manhattanPlot(js_data.manhattan_plot);
+ data = js_data.json_data;
+ d3.select("div#topchart").datum(data).call(mychart);
+ chrrect = mychart.chrSelect();
+ chrrect.on("mouseover", function() {
+ return d3.select(this).attr("fill", "#E9CFEC");
+ }).on("mouseout", function(d, i) {
+ return d3.select(this).attr("fill", function() {
+ if (i % 2) {
+ return "#F1F1F9";
+ }
+ return "#FBFBFF";
+ });
+ });
+ return mychart.markerSelect().on("click", function(d) {
+ var r;
+ r = d3.select(this).attr("r");
+ return d3.select(this).transition().duration(500).attr("r", r * 3).transition().duration(500).attr("r", r);
});
+};
+
+create_lod_chart()
-}).call(this);
+/*
+$(function() {
+ return root.create_lod_chart = create_lod_chart;
+});
+*/ \ No newline at end of file
diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html
index dd8ae236..4eb5862a 100644
--- a/wqflask/wqflask/templates/marker_regression_gn1.html
+++ b/wqflask/wqflask/templates/marker_regression_gn1.html
@@ -3,22 +3,23 @@
{% block css %}
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" />
+
+ <link rel="stylesheet" type="text/css" href="/static/new/css/marker_regression.css" />
+ <link rel="stylesheet" type="text/css" href="/static/new/css/panelutil.css" />
{% endblock %}
{% from "base_macro.html" import header %}
{% block content %}
- {{ header("Whole Genome Mapping Results",
- '{}: {}'.format(this_trait.name, this_trait.description_fmt)) }}
-
<div class="container">
<form method="post" target="_blank" action="/marker_regression" name="marker_regression" id="marker_regression_form">
<input type="hidden" name="temp_uuid" value="{{ temp_uuid }}">
<input type="hidden" name="trait_id" value="{{ this_trait.name }}">
<input type="hidden" name="dataset" value="{{ dataset.name }}">
+ <input type="hidden" name="method" value="{{ mapping_method }}">
+ {% if mapping_method != "gemma" %}
{% for sample in dataset.group.samplelist %}
<input type="hidden" name="value:{{ sample }}" value="{{ vals[loop.index - 1] }}">
{% endfor %}
<input type="hidden" name="maf">
- <input type="hidden" name="method" value="{{ mapping_method }}">
<input type="hidden" name="selected_chr" value="{{ selectedChr }}">
<input type="hidden" name="mb_range" value="{{ startMb|string + "," + endMb|string }}">
<input type="hidden" name="manhattan_plot">
@@ -28,13 +29,80 @@
<input type="hidden" name="mapmethod_rqtl_geno" value="{{ mapmethod_rqtl_geno }}">
<input type="hidden" name="mapmodel_rqtl_geno" value="{{ mapmodel_rqtl_geno }}">
<input type="hidden" name="pair_scan" value="{{ pair_scan }}">
- <div id="chart_container">
- <div class="qtlcharts" id="topchart">
- {{ gifmap|safe }}
- <img src="/static/output/{{ filename }}.jpeg" usemap="#WebQTLImageMap">
+ {% endif %}
+
+ <div class="container">
+ <div class="col-xs-5">
+ <h2>Map Viewer: Whole Genome</h2><br>
+ <b>Population:</b> {{ dataset.group.species|capitalize }} {{ dataset.group.name }}<br>
+ <b>Database:</b> {{ dataset.fullname }}<br>
+ {% if dataset.type == "ProbeSet" %}<b>Trait ID:</b>{% else %}<b>Record ID:</b>{% endif %} <a href="/show_trait?trait_id={{ this_trait.name }}&dataset={{ dataset.name }}">{{ this_trait.name }}</a><br>
+ {% if dataset.type == "ProbeSet" %}
+ <b>Gene Symbol:</b> <i>{{ this_trait.symbol }}</i><br>
+ <b>Location:</b> Chr {{ this_trait.chr }} @ {{ this_trait.mb }} Mb
+ {% endif %}
+ </div>
+ {% if mapping_method != "gemma" %}
+ <div id="gn1_map_options" class="col-xs-5" style="border:2px solid black; padding: 10px; margin: 10px;">
+ <div class="col-xs-7" style="padding-left: 0px;">
+ <table>
+ <tr>
+ <td><b>Chr:&nbsp;</b></td>
+ <td>
+ <select name="chromosomes" size="1">
+ {% for chr in ChrList %}
+ <option value="{{ chr[1] }}">{{ chr[0] }}</option>
+ {% endfor %}
+ </select>&nbsp;
+ <button type="button" class="btn btn-primary">Remap</button>
+ </td>
+ </tr>
+ <tr>
+ <td><b>View:&nbsp;</b></td>
+ <td>
+ <input type="text" name="startMb"
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="col-xs-3">
+ </div>
+ </div>
+ </div>
+ {% endif %}
+
+
+ <div class="tabbable" style="margin: 10px;">
+ <ul class="nav nav-tabs">
+ {% if mapping_method != "gemma" %}
+ <li id="gn1_map_tab">
+ <a href="#gn1_map" data-toggle="tab" aria-expanded="true">GN1 Map</a>
+ </li>
+ {% endif %}
+ <li id="vector_map_tab">
+ <a href="#vector_map" data-toggle="tab" {% if mapping_method != "gemma" %}aria-expanded="false"{% else %}aria-expanded="true"{% endif %}>Vector Map</a>
+ </li>
+ </ul>
+ <div class="tab-content">
+ {% if mapping_method != "gemma" %}
+ <div class="tab-pane active" id="gn1_map">
+ <div class="qtlcharts">
+ {{ gifmap|safe }}
+ <img src="/static/output/{{ filename }}.jpeg" usemap="#WebQTLImageMap">
+ </div>
</div>
+ {% endif %}
+ <div class="tab-pane {% if mapping_method == "gemma" %}active{% endif %}" id="vector_map">
+ <div id="chart_container">
+ <div class="qtlcharts" id="topchart"></div>
+ </div>
+ </div>
+ </div>
</div>
+
</form>
+
+ {% if mapping_method != "gemma" %}
<div style="width:48%;">
<h2>
Results
@@ -87,6 +155,7 @@
</tbody>
</table>
</div>
+ {% endif %}
</div>
<!-- End of body -->
@@ -95,8 +164,10 @@
{% block js %}
+ <script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="/static/new/js_external/underscore-min.js"></script>
<script type="text/javascript" src="/static/new/js_external/underscore.string.min.js"></script>
+ <script type="text/javascript" src="/static/new/js_external/d3-tip.min.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.js"></script>
<script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/dataTables.buttons.min.js"></script>
@@ -111,6 +182,11 @@
js_data = {{ js_data | safe }}
</script>
+ <script language="javascript" type="text/javascript" src="/static/new/javascript/panelutil.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/javascript/chr_lod_chart.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/javascript/lod_chart.js"></script>
+ <script language="javascript" type="text/javascript" src="/static/new/javascript/create_lodchart.js"></script>
+
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {
console.time("Creating table");
@@ -137,7 +213,15 @@
} );
console.timeEnd("Creating table");
- });
+ $('#vector_map_tab').click(function(){
+ $('div#gn1_map_options').hide();
+ });
+
+ $('#gn1_map_tab').click(function(){
+ $('div#gn1_map_options').show();
+ });
+
+ });
chrView = function(this_chr, chr_mb_list) {
$('input[name=selected_chr]').val(this_chr + 1)
@@ -148,10 +232,10 @@
rangeView = function(this_chr, start_mb, end_mb) {
$('input[name=selected_chr]').val(this_chr)
- $('input[name=mb_range]').val(start_mb + "," + end_mb)
-
- console.log("mb_range:", $('input[name=mb_range]').val())
-
+ $('input[name=startMb]').val(start_mb)
+ $('input[name=endMb]').val(end_mb)
+ //$('input[name=mb_range]').val(start_mb + "," + end_mb)
+
return $('#marker_regression_form').submit();
};
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 65b6dae4..17845826 100755
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -352,7 +352,8 @@ def marker_regression_page():
'control_marker_db',
'do_control',
'pair_scan',
- 'mb_range',
+ 'startMb',
+ 'endMb',
'mapmethod_rqtl_geno',
'mapmodel_rqtl_geno'
)
@@ -391,7 +392,8 @@ def marker_regression_page():
#for item in template_vars.__dict__.keys():
# print(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item))
- gn1_template_vars = marker_regression_gn1.MarkerRegression(result).__dict__
+ if start_vars['method'] != "gemma":
+ gn1_template_vars = marker_regression_gn1.MarkerRegression(result).__dict__
#qtl_length = len(result['js_data']['qtl_results'])
#print("qtl_length:", qtl_length)
@@ -414,7 +416,10 @@ def marker_regression_page():
rendered_template = render_template("pair_scan_results.html", **result)
else:
#rendered_template = render_template("marker_regression.html", **result)
- rendered_template = render_template("marker_regression_gn1.html", **gn1_template_vars)
+ if start_vars['method'] != "gemma":
+ rendered_template = render_template("marker_regression_gn1.html", **gn1_template_vars)
+ else:
+ rendered_template = render_template("marker_regression_gn1.html", **result)
return rendered_template