Skip to content

Commit

Permalink
Merge pull request #21 from wtsi-npg/devel
Browse files Browse the repository at this point in the history
merged for release 1.0.2
  • Loading branch information
jenniferliddle committed Feb 6, 2015
2 parents d8b05a7 + ef6281f commit b87ef53
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 22 deletions.
23 changes: 20 additions & 3 deletions js/src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

define(['jquery', 'd3'], function(jQuery, d3){
return function (divID, width, height) {
var drawChart = function (divID, width, height) {
if (!width) { width = jQuery(divID).data("width"); }
if (!width) { width = 500; }
if (!height) { height = jQuery(divID).data("height"); }
Expand Down Expand Up @@ -73,7 +73,7 @@ define(['jquery', 'd3'], function(jQuery, d3){
}
};

function format_adapter_chart (data) {
function format_adapter_chart (data) {
var formattedData = [];
for(var k in data.start_counts){
formattedData.push({xVar: parseInt(k, 10), yVar: data.start_counts[k]});
Expand Down Expand Up @@ -133,11 +133,20 @@ define(['jquery', 'd3'], function(jQuery, d3){
.ticks(10);

//define Y axis
var superscript = "⁰¹²³⁴⁵⁶⁷⁸⁹";
var vArray = [];
var n;
for (n=0; n<Math.log(yMax)/Math.LN10; n++) {
vArray.push(Math.pow(10,n));
}
vArray.push(Math.pow(10,n));

var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left")
.tickValues(vArray)
.ticks(5, function (d) {
if (d >= 1) { return Math.round(Math.log(d) / Math.LN10); }
if (d >= 1) { return "10"+superscript[Math.round(Math.log(d) / Math.LN10)]; }
});

//Create X axis
Expand Down Expand Up @@ -207,6 +216,14 @@ define(['jquery', 'd3'], function(jQuery, d3){
.attr('opacity', 0.6)
.attr('stroke-width', '1px')
.attr('stroke', 'white');

return 1;
}

return {
drawChart: drawChart,
_formatChart: format_adapter_chart,
_roundToPowerOfTen: roundToPowerOfTen,
};
});

23 changes: 10 additions & 13 deletions js/src/insertSizeHistogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ define(['jquery', 'd3'], function(jQuery, d3){
var xScale;
var yScale;

return function(divID) {
drawChart = function(divID) {
var data = jQuery(divID).data("check");
var width = jQuery(divID).data("width");
var height = jQuery(divID).data("height");
if(data && typeof data === "object" && data.bins != null){
if(data && typeof data === "object" && data.bins != null && data.bins.length > 1){
return new histogram(data, divID, width, height);
}else{
return null;
Expand Down Expand Up @@ -63,6 +63,8 @@ define(['jquery', 'd3'], function(jQuery, d3){
data.mean = +data.mean;
data.std = +data.std;
data.paired_reads_direction_in = +data.paired_reads_direction_in;
data.num_well_aligned_reads_opp_dir = +data.num_well_aligned_reads_opp_dir;
data.num_well_aligned_reads = +data.num_well_aligned_reads;
data.bins.forEach(function(v,i,a) { a[i]=+v; });

var xMin = data.min_isize;
Expand Down Expand Up @@ -148,16 +150,6 @@ define(['jquery', 'd3'], function(jQuery, d3){
//group for the bars
var bars = svg.append('g');

var bar_colour = 'blue';
if (data.paired_reads_direction_in) {
if (data.num_well_aligned_reads_opp_dir > data.num_well_aligned_reads) {
bar_colour = 'orange';
}
} else {
if (data.num_well_aligned_reads_opp_dir < data.num_well_aligned_reads) {
bar_colour = 'orange';
}
}
//draw bars in group
bars.selectAll('rect')
.data(data.bins)
Expand All @@ -167,7 +159,7 @@ define(['jquery', 'd3'], function(jQuery, d3){
.attr('y', function (d) { return yScale(d); })
.attr('width', nodeWidth)
.attr('height', function (d) { return height - padding.bottom - yScale(d); })
.attr('fill', bar_colour)
.attr('fill', data.paired_reads_direction_in ? "blue" : "orange")
.attr('opacity', 0.6)
.attr('stroke-width', '1px')
.attr('stroke', 'white');
Expand Down Expand Up @@ -228,4 +220,9 @@ define(['jquery', 'd3'], function(jQuery, d3){
.attr('fill', 'none');

}

return {
drawChart: drawChart,
};

});
10 changes: 7 additions & 3 deletions js/src/mismatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*
*/

define(['jquery','d3'], function(jQuery, d3){
return function (divID, width, height) {
define(['jquery','d3'], function(jQuery, d3) {
drawChart = function (divID, width, height) {
if (!width) { width = jQuery(divID).data("width"); }
if (!width) { width = 450; }
if (!height) { height = jQuery(divID).data("height"); }
Expand Down Expand Up @@ -136,9 +136,9 @@ define(['jquery','d3'], function(jQuery, d3){
.attr("width", w)
.attr("height", h);

var txt = 'Mismatch percent by cycle: run ' + data.id_run + ", position " + data.position;
if (title) {
padding.top = 50;
txt = 'Mismatch percent by cycle: run ' + data.id_run + ", position " + data.position;
if (data.tag_index) {
txt = txt + ", tag " + data.tag_index;
}
Expand Down Expand Up @@ -239,4 +239,8 @@ define(['jquery','d3'], function(jQuery, d3){
}

}

return {
drawChart: drawChart,
};
});
1 change: 1 addition & 0 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</fieldset>
<div style='clear:both;'></div>

<br />
<fieldset><legend>Sequence Mismatch</legend>
<div class="mismatch"></div>
</fieldset>
Expand Down
12 changes: 11 additions & 1 deletion test/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ define(
QUnit.test('adapter graph tests', function() {
var aJSON = {"forward_contaminated_read_count":1039,"forward_fasta_read_count":11981100,"forward_start_counts":{"1":829,"14":2,"15":23,"16":1,"17":1,"18":1,"19":2,"2":8,"20":91,"21":2,"23":1,"24":1,"25":1,"26":3,"27":3,"28":1,"29":8,"30":4,"31":3,"32":1,"33":3,"34":1,"36":1,"37":3,"38":5,"39":3,"40":6,"41":3,"42":3,"43":9,"44":4,"45":2,"46":8,"9":1},"id_run":"demo","position":"1","reverse_contaminated_read_count":345,"reverse_fasta_read_count":11981100,"reverse_start_counts":{"1":226,"14":1,"15":23,"16":1,"18":1,"19":1,"20":5,"21":1,"23":2,"24":1,"25":1,"26":3,"27":2,"28":2,"29":4,"30":2,"31":2,"32":3,"33":3,"34":3,"36":1,"37":2,"38":8,"39":2,"4":14,"40":4,"41":3,"42":1,"43":6,"44":8,"45":1,"46":9},"tag_index":"13"};
var h;
jQuery('.adapter').each(function(i) { jQuery(this).attr('data-check', JSON.stringify(aJSON)); h=adapter(this); });
jQuery('.adapter').each(function(i) {
jQuery(this).attr('data-check', JSON.stringify(aJSON));
jQuery(this).attr('data-width', 600);
jQuery(this).attr('data-height', 300);
h=adapter.drawChart(this);
});
QUnit.ok(h,"Created adapter ok");
QUnit.equal(adapter._roundToPowerOfTen(0),0,"Rounding is ok");
QUnit.equal(adapter._roundToPowerOfTen(1),1,"Rounding is ok");
QUnit.equal(adapter._roundToPowerOfTen(999),1000,"Rounding is ok");
QUnit.equal(adapter._roundToPowerOfTen(1001),10000,"Rounding is ok");
// d3.select('svg').remove();
});

};
return {run: run}
}
Expand Down
5 changes: 4 additions & 1 deletion test/insertSizeHistogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ define(
// var divId = jQuery('#graph')
// jQuery().attr('data-check', JSON.stringify(aJSON));
var h;
jQuery('.insert_size').each(function(i) { jQuery(this).attr('data-check',JSON.stringify(aJSON)); h=insertSizeHistogram(this); });
jQuery('.insert_size').each(function(i) {
jQuery(this).attr('data-check',JSON.stringify(aJSON));
h=insertSizeHistogram.drawChart(this);
});
QUnit.ok(h,"Created histogram ok");
// d3.select('svg').remove();
});
Expand Down
2 changes: 1 addition & 1 deletion test/mismatch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b87ef53

Please sign in to comment.