From e1b62e892ef132296429b1f6197686e4866ab648 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 18 Mar 2016 15:50:40 +0000 Subject: Replaced header with other information in qtl map Began adding menu to qtl map Fixed global search to not retrieve samples (to increase speed) Got the vector plot working again so it can be displayed alongside the gn1-style plot Only display the vector plot when doing GEMMA to speed up (this might not be necessary) --- wqflask/base/data_set.py | 9 +- wqflask/base/trait.py | 2 +- wqflask/wqflask/gsearch.py | 2 +- .../marker_regression/marker_regression_gn1.py | 7 +- .../static/new/javascript/create_lodchart.coffee | 4 - .../static/new/javascript/create_lodchart.js | 87 ++++++++-------- .../wqflask/templates/marker_regression_gn1.html | 110 ++++++++++++++++++--- wqflask/wqflask/views.py | 11 ++- 8 files changed, 163 insertions(+), 69 deletions(-) (limited to 'wqflask') 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 %} + + + {% endblock %} {% from "base_macro.html" import header %} {% block content %} - {{ header("Whole Genome Mapping Results", - '{}: {}'.format(this_trait.name, this_trait.description_fmt)) }} -
+ + {% if mapping_method != "gemma" %} {% for sample in dataset.group.samplelist %} {% endfor %} - @@ -28,13 +29,80 @@ -
-
- {{ gifmap|safe }} - + {% endif %} + +
+
+

Map Viewer: Whole Genome


+ Population: {{ dataset.group.species|capitalize }} {{ dataset.group.name }}
+ Database: {{ dataset.fullname }}
+ {% if dataset.type == "ProbeSet" %}Trait ID:{% else %}Record ID:{% endif %} {{ this_trait.name }}
+ {% if dataset.type == "ProbeSet" %} + Gene Symbol: {{ this_trait.symbol }}
+ Location: Chr {{ this_trait.chr }} @ {{ this_trait.mb }} Mb + {% endif %} +
+ {% if mapping_method != "gemma" %} +
+
+ + + + + + + + +
Chr:  +   + +
View:  + +
+
+
+
+
+
+ {% endif %} + + +
+ +
+ {% if mapping_method != "gemma" %} +
+
+ {{ gifmap|safe }} + +
+ {% endif %} +
+
+
+
+
+
+ + + {% if mapping_method != "gemma" %}

Results @@ -87,6 +155,7 @@

+ {% endif %}
@@ -95,8 +164,10 @@ {% block js %} + + @@ -111,6 +182,11 @@ js_data = {{ js_data | safe }} + + + + +