diff options
author | Zachary Sloan | 2013-08-08 16:23:43 -0500 |
---|---|---|
committer | Zachary Sloan | 2013-08-08 16:23:43 -0500 |
commit | f155e26112f088c908c0654a57a40ff1f8fe23cc (patch) | |
tree | baebc6200ddf971a63dbcdab6206d0abb72a0ece | |
parent | 8993b25262b7fc565c1be3548660a66afd4c3530 (diff) | |
download | genenetwork2-f155e26112f088c908c0654a57a40ff1f8fe23cc.tar.gz |
Fixed issue where points in marker regression manhattan plot
weren't positioned on the x-axis
-rw-r--r-- | wqflask/wqflask/static/new/javascript/marker_regression.coffee | 20 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/marker_regression.js | 16 |
2 files changed, 26 insertions, 10 deletions
diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.coffee b/wqflask/wqflask/static/new/javascript/marker_regression.coffee index 2221e030..2892987e 100644 --- a/wqflask/wqflask/static/new/javascript/marker_regression.coffee +++ b/wqflask/wqflask/static/new/javascript/marker_regression.coffee @@ -25,6 +25,8 @@ $ -> #@x_max = d3.max(@x_coords) @x_max = @total_length + console.log("@x_max: ", @x_max) + console.log("@x_buffer: ", @x_buffer) @y_max = d3.max(@y_coords) * 1.2 @svg = @create_svg() @@ -53,6 +55,8 @@ $ -> ### + console.log("@chromosomes: ", @chromosomes) + cumulative_chr_lengths = [] chr_lengths = [] total_length = 0 @@ -61,8 +65,8 @@ $ -> chr_lengths.push(this_length) cumulative_chr_lengths.push(total_length + this_length) total_length += this_length - - #console.log("total length is:", total_length) + + console.log("chr_lengths: ", chr_lengths) return [chr_lengths, cumulative_chr_lengths] @@ -70,16 +74,20 @@ $ -> chr_lengths = [] chr_seen = [] for result in js_data.qtl_results - chr_length = @chromosomes[result.chr] + if result.chr == "X" + chr_length = parseFloat(@chromosomes[20]) + else + chr_length = parseFloat(@chromosomes[result.chr]) if not(result.chr in chr_seen) chr_seen.push(result.chr) chr_lengths.push(chr_length) if result.chr != "1" - @total_length += chr_lengths[chr_lengths.length - 2] + @total_length += parseFloat(chr_lengths[chr_lengths.length - 2]) @x_coords.push(@total_length + parseFloat(result.Mb)) @y_coords.push(result.lod_score) @marker_names.push(result.name) - @total_length += chr_lengths[chr_lengths.length-1] + @total_length += parseFloat(chr_lengths[chr_lengths.length-1]) + #console.log("chr_lengths: ", chr_lengths) show_marker_in_table: (marker_info) -> console.log("in show_marker_in_table") @@ -271,7 +279,7 @@ $ -> .enter() .append("circle") .attr("cx", (d) => - return parseFloat(@x_buffer + ((@plot_width-@x_buffer) * d[0]/@x_max)) + return parseFloat(@x_buffer) + ((parseFloat(@plot_width)-parseFloat(@x_buffer)) * d[0]/parseFloat(@x_max)) ) .attr("cy", (d) => return @plot_height - ((@plot_height-@y_buffer) * d[1]/@y_max) diff --git a/wqflask/wqflask/static/new/javascript/marker_regression.js b/wqflask/wqflask/static/new/javascript/marker_regression.js index a2b2ff57..ffcf1a75 100644 --- a/wqflask/wqflask/static/new/javascript/marker_regression.js +++ b/wqflask/wqflask/static/new/javascript/marker_regression.js @@ -27,6 +27,8 @@ this.x_buffer = this.plot_width / 30; this.y_buffer = this.plot_height / 20; this.x_max = this.total_length; + console.log("@x_max: ", this.x_max); + console.log("@x_buffer: ", this.x_buffer); this.y_max = d3.max(this.y_coords) * 1.2; this.svg = this.create_svg(); this.plot_coordinates = _.zip(this.x_coords, this.y_coords, this.marker_names); @@ -61,6 +63,7 @@ */ var chr_lengths, cumulative_chr_lengths, key, this_length, total_length; + console.log("@chromosomes: ", this.chromosomes); cumulative_chr_lengths = []; chr_lengths = []; total_length = 0; @@ -70,6 +73,7 @@ cumulative_chr_lengths.push(total_length + this_length); total_length += this_length; } + console.log("chr_lengths: ", chr_lengths); return [chr_lengths, cumulative_chr_lengths]; }; @@ -80,19 +84,23 @@ _ref = js_data.qtl_results; for (_i = 0, _len = _ref.length; _i < _len; _i++) { result = _ref[_i]; - chr_length = this.chromosomes[result.chr]; + if (result.chr === "X") { + chr_length = parseFloat(this.chromosomes[20]); + } else { + chr_length = parseFloat(this.chromosomes[result.chr]); + } if (!(_ref1 = result.chr, __indexOf.call(chr_seen, _ref1) >= 0)) { chr_seen.push(result.chr); chr_lengths.push(chr_length); if (result.chr !== "1") { - this.total_length += chr_lengths[chr_lengths.length - 2]; + this.total_length += parseFloat(chr_lengths[chr_lengths.length - 2]); } } this.x_coords.push(this.total_length + parseFloat(result.Mb)); this.y_coords.push(result.lod_score); this.marker_names.push(result.name); } - return this.total_length += chr_lengths[chr_lengths.length - 1]; + return this.total_length += parseFloat(chr_lengths[chr_lengths.length - 1]); }; Manhattan_Plot.prototype.show_marker_in_table = function(marker_info) { @@ -248,7 +256,7 @@ Manhattan_Plot.prototype.add_plot_points = function() { var _this = this; return this.svg.selectAll("circle").data(this.plot_coordinates).enter().append("circle").attr("cx", function(d) { - return parseFloat(_this.x_buffer + ((_this.plot_width - _this.x_buffer) * d[0] / _this.x_max)); + return parseFloat(_this.x_buffer) + ((parseFloat(_this.plot_width) - parseFloat(_this.x_buffer)) * d[0] / parseFloat(_this.x_max)); }).attr("cy", function(d) { return _this.plot_height - ((_this.plot_height - _this.y_buffer) * d[1] / _this.y_max); }).attr("r", 2).attr("id", function(d) { |