From 5cd0e91c1de07b8932d0ff973660607605122bcc Mon Sep 17 00:00:00 2001 From: christian Date: Wed, 3 Aug 2016 16:27:57 +0200 Subject: Add settings & routing for serving Biodalliance --- wqflask/wqflask/views.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 70e465d1..7d3caea4 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -106,6 +106,12 @@ def tmp_page(img_path): img_base64 = bytesarray ) +@app.route("/dalliance/") +def bd_files(file_path): + bd_path = app.config['BIODALLIANCE_PATH'] + return send_from_directory(bd_path, file_path) + + #@app.route("/data_sharing") #def data_sharing_page(): # logger.info("In data_sharing") -- cgit v1.2.3 From 5ea6eb6ad7c529dcf8f2a9b24f6186f8571341a1 Mon Sep 17 00:00:00 2001 From: christian Date: Wed, 3 Aug 2016 16:28:58 +0200 Subject: Return to full view button in vector map view --- wqflask/wqflask/templates/marker_regression_gn1.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index 978ea55f..2fb2a36d 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -160,8 +160,19 @@ {% if mapping_method != "gemma" %}
-
-
+
+
+ Return to full view +
+ +
+ Open BioDalliance view +
+ +
+ +
+
{% endif %} @@ -319,6 +330,10 @@ $('div#gn1_map_options').show(); }); + $('#open_bd').click(function() { + console.log($('#topchart').contents()); + }) + }); chrView = function(this_chr, chr_mb_list) { -- cgit v1.2.3 From b8e9edd94fcd1f2630915b888993ee39e8f4e53b Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 4 Aug 2016 16:54:26 +0200 Subject: Fix so BD subfolders are served --- wqflask/wqflask/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 7d3caea4..55efd7e4 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -106,10 +106,10 @@ def tmp_page(img_path): img_base64 = bytesarray ) -@app.route("/dalliance/") -def bd_files(file_path): +@app.route("/dalliance/") +def bd_files(filename): bd_path = app.config['BIODALLIANCE_PATH'] - return send_from_directory(bd_path, file_path) + return send_from_directory(bd_path, filename) #@app.route("/data_sharing") -- cgit v1.2.3 From 32afb970e6ac87c4dc71b5b5fe698a2892d7b1d8 Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 4 Aug 2016 16:54:54 +0200 Subject: Add function for creating a basic BD browser --- .../wqflask/static/new/javascript/biodalliance.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 wqflask/wqflask/static/new/javascript/biodalliance.js (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/biodalliance.js b/wqflask/wqflask/static/new/javascript/biodalliance.js new file mode 100644 index 00000000..6b082fbb --- /dev/null +++ b/wqflask/wqflask/static/new/javascript/biodalliance.js @@ -0,0 +1,24 @@ +"use strict"; + +var createBDBrowser = function(chr, start, end, sources) { + console.log("creating BD browser"); + var b = new Browser({ + chr: chr, + viewStart: start, + viewEnd: end, + + coordSystem: { + speciesName: 'Mouse' + }, + + sources: sources, + + setDocumentTitle: false, + prefix: '/dalliance/', + noPersist: true, + pageName: 'bd_container' + }); + + console.log("created BD browser"); + return b; +}; -- cgit v1.2.3 From c55bb30fd7cd54a5065074f19cd6ed64fa6d79f1 Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 4 Aug 2016 16:55:36 +0200 Subject: Add placeholder BD browser to marker_regressions --- .../wqflask/templates/marker_regression_gn1.html | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index 2fb2a36d..8934aa62 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -280,10 +280,15 @@ + + + {% endif %} {% endblock %} - -- cgit v1.2.3 From e826ee732b9b7b900427d85e6e94f645c83586c9 Mon Sep 17 00:00:00 2001 From: christian Date: Fri, 5 Aug 2016 15:51:44 +0200 Subject: Add functions for creating, configuring BD browser --- .../wqflask/static/new/javascript/biodalliance.js | 55 +++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/biodalliance.js b/wqflask/wqflask/static/new/javascript/biodalliance.js index 6b082fbb..2dde6365 100644 --- a/wqflask/wqflask/static/new/javascript/biodalliance.js +++ b/wqflask/wqflask/static/new/javascript/biodalliance.js @@ -1,6 +1,13 @@ "use strict"; -var createBDBrowser = function(chr, start, end, sources) { +var bd_browser = null; +var bd_data = {}; + +var getChrLen = function(chr) { + return js_data[chr * 1]; +}; + +var createBDBrowser = function(chr, start, end, speciesName, sources) { console.log("creating BD browser"); var b = new Browser({ chr: chr, @@ -8,7 +15,7 @@ var createBDBrowser = function(chr, start, end, sources) { viewEnd: end, coordSystem: { - speciesName: 'Mouse' + speciesName: speciesName }, sources: sources, @@ -22,3 +29,47 @@ var createBDBrowser = function(chr, start, end, sources) { console.log("created BD browser"); return b; }; + +var showBDButton = function() { + $('#open_bd').show(); + $('#close_bd').hide(); +}; + +var hideBDButton = function() { + $('#close_bd').show(); + $('#open_bd').hide(); +}; + + +var setBDData = function(chr, length) { + // bd_data = { chr: chr, length: length }; + bd_data.chr = chr; + bd_data.length = length; +}; + +var setBDSpecies = function(species) { + bd_data.species = species; +}; + + +var openBDBrowser = function() { + console.log("opening browser"); + if (!bd_browser) { + bd_browser = createBDBrowser(bd_data.chr, 0, bd_data.length * 1000000, bd_data.species, + [{name: 'Genome', + twoBitURI: 'http://www.biodalliance.org/datasets/GRCm38/mm10.2bit', + desc: 'Mouse reference genome build GRCm38', + tier_type: 'sequence', + provides_entrypoints: true}, + {name: 'QTL', + tier_type: 'qtl', + uri: 'http://gsocbox:8880/static/qtl/lod2.csv', + stylesheet_uri: "http://gsocbox:8880/stylesheets/qtl-stylesheet.xml" + }] + ); + } else { + bd_browser.setLocation(bd_data.chr, 0, bd_data.length * 1000000); + } + + bd_browser.maxViewWidth = bd_data.length * 1000000; +}; -- cgit v1.2.3 From fca32bd6a76cbf2248c4c19129daa1453092ba97 Mon Sep 17 00:00:00 2001 From: christian Date: Fri, 5 Aug 2016 15:55:09 +0200 Subject: Add show & hide BD buttons to single chr view --- .../static/new/javascript/chr_lod_chart.coffee | 1 + .../wqflask/static/new/javascript/chr_lod_chart.js | 31 +++-------- .../wqflask/static/new/javascript/lod_chart.coffee | 2 + wqflask/wqflask/static/new/javascript/lod_chart.js | 60 +++++++++------------- 4 files changed, 33 insertions(+), 61 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee b/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee index e00694be..d3c1ee7d 100644 --- a/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee +++ b/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee @@ -273,6 +273,7 @@ class Chr_Lod_Chart $("#return_to_full_view").hide() $('#topchart').remove() $('#chart_container').append('
') + hideBDButton() create_lod_chart() show_marker_in_table: (marker_info) -> diff --git a/wqflask/wqflask/static/new/javascript/chr_lod_chart.js b/wqflask/wqflask/static/new/javascript/chr_lod_chart.js index c6cbd01b..0032858f 100644 --- a/wqflask/wqflask/static/new/javascript/chr_lod_chart.js +++ b/wqflask/wqflask/static/new/javascript/chr_lod_chart.js @@ -1,13 +1,12 @@ -// Generated by CoffeeScript 1.9.2 +// Generated by CoffeeScript 1.10.0 var Chr_Lod_Chart; Chr_Lod_Chart = (function() { - function Chr_Lod_Chart(plot_height, plot_width, chr, manhattanPlot, mappingScale) { + function Chr_Lod_Chart(plot_height, plot_width, chr, manhattanPlot) { this.plot_height = plot_height; this.plot_width = plot_width; this.chr = chr; this.manhattanPlot = manhattanPlot; - this.mappingScale = mappingScale; this.qtl_results = js_data.qtl_results; console.log("qtl_results are:", this.qtl_results); console.log("chr is:", this.chr); @@ -66,6 +65,8 @@ Chr_Lod_Chart = (function() { } else { this_chr = result.chr; } + console.log("this_chr is:", this_chr); + console.log("@chr[0] is:", parseInt(this.chr[0])); if (this_chr > parseInt(this.chr[0])) { break; } @@ -95,18 +96,11 @@ Chr_Lod_Chart = (function() { Chr_Lod_Chart.prototype.create_coordinates = function() { var i, len, ref, result, results; ref = this.these_results; - console.log("THESE_RESULTS:", ref) results = []; for (i = 0, len = ref.length; i < len; i++) { result = ref[i]; this.x_coords.push(parseFloat(result.Mb)); - if (js_data.result_score_type == "LOD") { - this.y_coords.push(result.lod_score); - } - else { - console.log("LRS VALUE:", result['lrs_value']) - this.y_coords.push(result['lrs_value']); - } + this.y_coords.push(result.lod_score); results.push(this.marker_names.push(result.name)); } return results; @@ -119,19 +113,7 @@ Chr_Lod_Chart = (function() { }; Chr_Lod_Chart.prototype.create_scales = function() { - if (this.mappingScale == "morgan") { - max_pos = 0 - for (i = 0, len = this.these_results.length; i < len; i++) { - marker = this.these_results[i] - if (parseFloat(marker['Mb']) > max_pos){ - max_pos = parseFloat(marker.Mb) - } - } - this.x_scale = d3.scale.linear().domain([0, max_pos]).range([this.x_buffer, this.plot_width]); - } - else { - this.x_scale = d3.scale.linear().domain([0, this.chr[1]]).range([this.x_buffer, this.plot_width]); - } + this.x_scale = d3.scale.linear().domain([0, this.chr[1]]).range([this.x_buffer, this.plot_width]); return this.y_scale = d3.scale.linear().domain([0, this.y_max]).range([this.plot_height, this.y_buffer]); }; @@ -278,6 +260,7 @@ Chr_Lod_Chart = (function() { $("#return_to_full_view").hide(); $('#topchart').remove(); $('#chart_container').append('
'); + hideBDButton(); return create_lod_chart(); }; diff --git a/wqflask/wqflask/static/new/javascript/lod_chart.coffee b/wqflask/wqflask/static/new/javascript/lod_chart.coffee index 55ffdce0..2da2e5bb 100644 --- a/wqflask/wqflask/static/new/javascript/lod_chart.coffee +++ b/wqflask/wqflask/static/new/javascript/lod_chart.coffee @@ -123,6 +123,8 @@ lodchart = () -> .on("click", (d) -> console.log("d is:", d) redraw_plot(d) + setBDData(d[0], d[1]) + showBDButton() ) # x-axis labels diff --git a/wqflask/wqflask/static/new/javascript/lod_chart.js b/wqflask/wqflask/static/new/javascript/lod_chart.js index 014bf59b..c6d1045c 100644 --- a/wqflask/wqflask/static/new/javascript/lod_chart.js +++ b/wqflask/wqflask/static/new/javascript/lod_chart.js @@ -1,8 +1,8 @@ -// Generated by CoffeeScript 1.9.2 +// Generated by CoffeeScript 1.10.0 var lodchart; lodchart = function() { - var additive, additive_ylab, additive_ylim, additive_yscale, additive_yticks, additivelinecolor, axispos, chart, chrGap, chrSelect, darkrect, height, lightrect, linewidth, lodcurve, lodlinecolor, lodvarname, manhattanPlot, mappingScale, margin, markerSelect, nyticks, pad4heatmap, pointcolor, pointsAtMarkers, pointsize, pointstroke, rotate_ylab, significantcolor, suggestivecolor, title, titlepos, width, xlab, xscale, ylab, ylim, yscale, yticks; + var additive, additive_ylab, additive_ylim, additive_yscale, additive_yticks, additivelinecolor, axispos, chart, chrGap, chrSelect, darkrect, height, lightrect, linewidth, lodcurve, lodlinecolor, lodvarname, manhattanPlot, margin, markerSelect, nyticks, pad4heatmap, pointcolor, pointsAtMarkers, pointsize, pointstroke, rotate_ylab, significantcolor, suggestivecolor, title, titlepos, width, xlab, xscale, ylab, ylim, yscale, yticks; width = 800; height = 500; margin = { @@ -20,6 +20,7 @@ lodchart = function() { }; titlepos = 20; manhattanPlot = false; + additive = false; ylim = null; additive_ylim = null; nyticks = 5; @@ -29,8 +30,7 @@ lodchart = function() { darkrect = "#F1F1F9"; lightrect = "#FBFBFF"; lodlinecolor = "darkslateblue"; - additivelinecolor_plus = "red"; - additivelinecolor_negative = "green"; + additivelinecolor = "red"; linewidth = 2; suggestivecolor = "gainsboro"; significantcolor = "#EBC7C7"; @@ -70,15 +70,14 @@ lodchart = function() { return results; })(); ylim = ylim != null ? ylim : [0, d3.max(data[lodvarname])]; - - if ('additive' in data) { + if (additive) { data['additive'] = (function() { var j, len, ref, results; ref = data['additive']; results = []; for (j = 0, len = ref.length; j < len; j++) { x = ref[j]; - results.push(x); + results.push(Math.abs(x)); } return results; })(); @@ -92,12 +91,12 @@ lodchart = function() { g.append("rect").attr("x", margin.left).attr("y", margin.top).attr("height", height).attr("width", width).attr("fill", darkrect).attr("stroke", "none"); yscale.domain(ylim).range([height + margin.top, margin.top + margin.inner]); yticks = yticks != null ? yticks : yscale.ticks(nyticks); - if ('additive' in data) { + if (additive) { additive_yscale.domain(additive_ylim).range([height + margin.top, margin.top + margin.inner + height / 2]); additive_yticks = additive_yticks != null ? additive_yticks : additive_yscale.ticks(nyticks); } reorgLodData(data, lodvarname); - data = chrscales(data, width, chrGap, margin.left, pad4heatmap, mappingScale); + data = chrscales(data, width, chrGap, margin.left, pad4heatmap); xscale = data.xscale; chrSelect = g.append("g").attr("class", "chrRect").selectAll("empty").data(data.chrnames).enter().append("rect").attr("id", function(d) { return "chrrect" + d[0]; @@ -118,7 +117,9 @@ lodchart = function() { return lightrect; }).attr("stroke", "none").on("click", function(d) { console.log("d is:", d); - return redraw_plot(d); + redraw_plot(d); + setBDData(d[0], d[1]); + return showBDButton(); }); xaxis = g.append("g").attr("class", "x axis"); xaxis.selectAll("empty").data(data.chrnames).enter().append("text").text(function(d) { @@ -133,7 +134,7 @@ lodchart = function() { var chr_plot; $('#topchart').remove(); $('#chart_container').append('
'); - return chr_plot = new Chr_Lod_Chart(600, 1200, chr_ob, manhattanPlot, mappingScale); + return chr_plot = new Chr_Lod_Chart(600, 1200, chr_ob, manhattanPlot); }; rotate_ylab = rotate_ylab != null ? rotate_ylab : ylab.length > 1; yaxis = g.append("g").attr("class", "y axis"); @@ -148,7 +149,7 @@ lodchart = function() { return formatAxis(yticks)(d); }); yaxis.append("text").attr("class", "title").attr("y", margin.top + height / 2).attr("x", margin.left - axispos.ytitle).text(ylab).attr("transform", rotate_ylab ? "rotate(270," + (margin.left - axispos.ytitle) + "," + (margin.top + height / 2) + ")" : "").attr("text-anchor", "middle").attr("fill", "slateblue"); - if ('additive' in data) { + if (additive) { rotate_additive_ylab = rotate_additive_ylab != null ? rotate_additive_ylab : additive_ylab.length > 1; additive_yaxis = g.append("g").attr("class", "y axis"); additive_yaxis.selectAll("empty").data(additive_yticks).enter().append("line").attr("y1", function(d) { @@ -187,19 +188,13 @@ lodchart = function() { return yscale(data.lodByChr[chr][i][lodcolumn]); }); }; - if ('additive' in data) { + if (additive) { additivecurve = function(chr, lodcolumn) { - if (data.additiveByChr[chr][0] < 0) { - pos_neg = "negative" - } - else { - pos_neg = "positive" - } - return [pos_neg, d3.svg.line().x(function(d) { + return d3.svg.line().x(function(d) { return xscale[chr](d); }).y(function(d, i) { - return additive_yscale(Math.abs(data.additiveByChr[chr][i])); - })]; + return additive_yscale(data.additiveByChr[chr][i][lodcolumn]); + }); }; } curves = g.append("g").attr("id", "curves"); @@ -210,17 +205,12 @@ lodchart = function() { curves.append("path").datum(data.posByChr[chr[0]]).attr("d", lodcurve(chr[0], lodvarnum)).attr("stroke", lodlinecolor).attr("fill", "none").attr("stroke-width", linewidth).style("pointer-events", "none"); } } - if ('additive' in data) { + if (additive) { ref1 = data.chrnames; for (k = 0, len1 = ref1.length; k < len1; k++) { chr = ref1[k]; if (chr.indexOf(data['chr'])) { - if (additivecurve(chr[0], lodvarnum)[0] == "negative") { - curves.append("path").datum(data.posByChr[chr[0]]).attr("d", additivecurve(chr[0], lodvarnum)[1]).attr("stroke", additivelinecolor_negative).attr("fill", "none").attr("stroke-width", 1).style("pointer-events", "none"); - } - else { - curves.append("path").datum(data.posByChr[chr[0]]).attr("d", additivecurve(chr[0], lodvarnum)[1]).attr("stroke", additivelinecolor_plus).attr("fill", "none").attr("stroke-width", 1).style("pointer-events", "none"); - } + curves.append("path").datum(data.posByChr[chr[0]]).attr("d", additivecurve(chr[0], lodvarnum)).attr("stroke", additivelinecolor).attr("fill", "none").attr("stroke-width", 1).style("pointer-events", "none"); } } } @@ -305,13 +295,6 @@ lodchart = function() { manhattanPlot = value; return chart; }; - chart.mappingScale = function(value) { - if (!arguments.length) { - return mappingScale; - } - mappingScale = value; - return chart; - }; chart.ylim = function(value) { if (!arguments.length) { return ylim; @@ -449,6 +432,9 @@ lodchart = function() { chart.yscale = function() { return yscale; }; + chart.additive = function() { + return additive; + }; chart.additive_yscale = function() { return additive_yscale; }; @@ -470,4 +456,4 @@ lodchart = function() { return chrSelect; }; return chart; -}; \ No newline at end of file +}; -- cgit v1.2.3 From 30b1f225934cec2f64a32b22efd3f961e67a8bd8 Mon Sep 17 00:00:00 2001 From: christian Date: Fri, 5 Aug 2016 15:56:03 +0200 Subject: Hide BD buttons by default, send species to BD --- .../wqflask/templates/marker_regression_gn1.html | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index 8934aa62..efb80494 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -161,14 +161,18 @@ {% if mapping_method != "gemma" %}
-
+ -
+ + +
@@ -287,7 +291,7 @@