From 9e9c22aae22428fa29ec1995930d55eae8b4dc5c Mon Sep 17 00:00:00 2001 From: corywang Date: Fri, 17 Apr 2015 11:10:41 -0400 Subject: [PATCH] Added above/below colored genes based on score --- Tile2contentsnpplotter.txt | 14 ++++++------- VQI_GenomeBrowser.js | 40 +++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Tile2contentsnpplotter.txt b/Tile2contentsnpplotter.txt index 8ecf41e..064ff93 100644 --- a/Tile2contentsnpplotter.txt +++ b/Tile2contentsnpplotter.txt @@ -10,27 +10,27 @@ chr9_gl000198_random 77493 77494 . 0 + chr4_gl000193_random 86356 86357 . 0 + chr4_gl000193_random 86519 86520 . 0 + chr1 896004 896005 . 0 + -chr1 976170 976171 . 0 + +chr1 976170 976171 . -.4 + chr1 1198674 1198675 . 0 + -chr1 1250433 1250434 . 0 + +chr1 1250433 1250434 . 1 + chr1 1597292 1597293 rs79791328 0 + chr1 1597292 1597293 rs79791328 0 + chr1 1688189 1688190 . 0 + chr1 1897981 1897982 . 0 + -chr1 1987060 1987061 . 0 + +chr1 1987060 1987061 . -3 + chr1 3555382 3555383 . 0 + -chr1 3692443 3692444 . 0 + +chr1 3692443 3692444 . 1 + chr1 6142182 6142183 . 0 + chr1 9027765 9027766 . 0 + chr1 9785114 9785115 . 0 + chr1 12025665 12025666 . 0 + chr1 12320683 12320684 . 0 + -chr1 12780679 12780680 . 0 + +chr1 12780679 12780680 . 1 + chr1 16053894 16053895 . 0 + chr1 16580123 16580124 . 0 + -chr1 17555405 17555406 . 0 + +chr1 17555405 17555406 . .5 + chr1 18016317 18016318 . 0 + -chr1 18017563 18017564 . 0 + +chr1 18017563 18017564 . 1 + chr1 21103040 21103041 . 0 + chr1 21582581 21582582 rs79178176 0 + chr1 22055122 22055123 rs151180337 0 + diff --git a/VQI_GenomeBrowser.js b/VQI_GenomeBrowser.js index d266286..b0d01ff 100755 --- a/VQI_GenomeBrowser.js +++ b/VQI_GenomeBrowser.js @@ -603,11 +603,20 @@ function VQI_GenomeBrowser(id) { }) //.attr("transform", "translate(" + 0 + "," + thisY + ")"); + //Just a line + trackGroup.selectAll("line").data([name], function (d) { + return d; + }).enter().append("line") + .attr("x1", 0) + .attr("y1", 0) + .attr("x2", width) + .attr("y2", 0) + .style("stroke", "blue") + .style("stroke-opacity" , 0.5); trackGroup.selectAll("text").data([name], function (d) { return d; }).enter().append("text") - .attr("class", name) .attr("x", 0) .attr("y", -trackHeight / 2 - bufferSpace / 2) .attr("font-family", "sans-serif") @@ -647,7 +656,7 @@ function VQI_GenomeBrowser(id) { .append("xhtml:body") .html("
") .on("click", function (d, i) { - console.log(trackGroup.select("#check").node().checked); + //console.log(trackGroup.select("#check").node().checked); xAxisSelection.call(xAxis);//I have no idea why it won't redraw the checkbox unless I call this }); } @@ -722,17 +731,6 @@ function VQI_GenomeBrowser(id) { var addCpgTrack = function (data, name) { - //Just a line - graphRegion.selectAll("g").data([name], function (d) { - return d; - }) - .append("line") - .attr("x1", 0) - .attr("y1", 0) - .attr("x2", width) - .attr("y2", 0) - .style("stroke", "blue"); - var trackScalableGroup = graphRegion.selectAll("g").data([name], function (d) { return d; }).select("g.scalable"); @@ -846,14 +844,20 @@ function VQI_GenomeBrowser(id) { .attr("x", function (d) { return fullXScale(d[indexArray.start]); }) - .attr("y", -1) + .attr("y", function (d) { + return d[indexArray.score] > 0 ? -5 : 0; + }) .attr("height", 5) .attr("width", function (d) { return fullXScale(d[indexArray.end]) - fullXScale(d[indexArray.start]); }) .style("fill-opacity", "1") - .style("stroke", "black") - .style("fill", "black") + .style("stroke", function (d) { + return d[indexArray.score] > 0 ? "red" : "green"; + }) + .style("fill", function (d) { + return d[indexArray.score] > 0 ? "red" : "green"; + }) .style("vector-effect", "non-scaling-stroke") .attr("class", "scalable") /*.attr("x1", function (d) { @@ -914,8 +918,8 @@ function VQI_GenomeBrowser(id) { .attr("x", function (d) { return fullXScale(d[indexArray.start]); }) - .attr("y", -trackHeight / 2) - .attr("height", trackHeight) + .attr("y", -2.5) + .attr("height", 5) .attr("width", function (d) { return fullXScale(d[indexArray.end]) - fullXScale(d[indexArray.start]); })