diff options
author | christian | 2016-08-05 15:55:09 +0200 |
---|---|---|
committer | christian | 2016-08-05 15:55:09 +0200 |
commit | fca32bd6a76cbf2248c4c19129daa1453092ba97 (patch) | |
tree | 7a9e2b7b028b36b74425d34692a01a0dc6b788fa | |
parent | e826ee732b9b7b900427d85e6e94f645c83586c9 (diff) | |
download | genenetwork2-fca32bd6a76cbf2248c4c19129daa1453092ba97.tar.gz |
Add show & hide BD buttons to single chr view
4 files changed, 33 insertions, 61 deletions
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('<div class="qtlcharts" id="topchart"></div>')
+ 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('<div class="qtlcharts" id="topchart"></div>'); + 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('<div class="qtlcharts" id="topchart"></div>'); - 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 +}; |