-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1604 lines (1544 loc) · 65 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>fastQC</title>
<style>
table {
margin-left: 3em;
text-align: center;
}
th {
text-align: center;
background-color: #000080;
color: #FFFFFF;
padding: 0.4em;
}
td {
font-family: monospace;
text-align: left;
background-color: #EEEEEE;
color: #000000;
padding: 0.4em;
}
.axis text, .yaxis text {
font: 10px sans-serif;
}
.axis path, .axis line, .yaxis path {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.divs {
float: left;
width: 33.3%;
}
.mainDiv {
width: 2500px;
}
.aggregateRects {
opacity: 1;
}
.aggregateRects:hover {
opacity: 0.7;
cursor: pointer;
}
.pointerImage, .lineMouseover{
cursor: pointer;
}
.y-axis-title {
font-family: "Lucida Console", Courier, monospace;
font-size: small;
}
.x-axis-title {
font-family: "Lucida Console", Courier, monospace;
font-size: small;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="singlefile.js"></script>
<script src="groups.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/js/select2.min.js"></script>
</head>
<body>
<hr />
File Input:
<input type="file" id="qcFile" name="qcFile[]" onchange="readFile(this.files)" multiple="multiple">
Choose file:
<select id="slct" name = "slct" onchange="fileSelect(this.value)"> </select>
Groups:
<select id="selected-groups" class="selected-groups" name="selected-groups"
multiple="multiple" style="width: 300px;" onchange="groupsFunctions()"></select>
<hr />
<div id="main" class="mainDiv">
<div id="left" class="divs">
<h2 id="one"></h2>
<div id="container1"> </div>
<h2 id="two"></h2>
<div id="container2"></div>
<h2 id="three"></h2>
<div id="container3"></div>
<h2 id="four"></h2>
<div id="container4"></div>
<h2 id="five"></h2>
<div id="container5"></div>
<h2 id="six"></h2>
<div id="container6"></div>
<h2 id="seven"></h2>
<div id="container7"></div>
<h2 id="eight"></h2>
<div id="container8"></div>
<h2 id="nine"></h2>
<div id="container9"></div>
<h2 id="ten"></h2>
<div id="container10"></div>
<h2 id="eleven"></h2>
<div id="container11"></div>
<h2 id="twelve"></h2>
<div id="container12"></div>
</div>
<div id="right" class="divs">
<h2 id="thirteen"></h2>
<div id="container13"></div>
<h2 id="fourteen"></h2>
<div id="container14"></div>
<h2 id="fifteen"></h2>
<div id="container15"></div>
<h2 id="sixteen"></h2>
<div id="container16"></div>
<h2 id="seventeen"></h2>
<div id="container17"></div>
<h2 id="eightteen"></h2>
<div id="container18"></div>
<h2 id="nineteen"></h2>
<div id="container19"></div>
<h2 id="twenty"></h2>
<div id="container20"></div>
<h2 id="twentyone"></h2>
<div id="container21"></div>
<h2 id="twentytwo"></h2>
<div id="container22"></div>
</div>
<div id="groups" class="divs">
<h2 id="groups1"></h2>
<div id="groupscontainer1"></div>
<h2 id="groups2"></h2>
<div id="groupscontainer2"></div>
<h2 id="groupscontainer3-tabs"></h2>
<div id="groups3tabs">
<ul>
<li><a href="#tab1" style="font-size: 0.5em;">Adapter Content</a></li>
<li><a href="#tab2" style="font-size: 0.5em;">Basic Stats</a></li>
<li><a href="#tab3" style="font-size: 0.5em;">Kmer Content</a></li>
<li><a href="#tab4" style="font-size: 0.5em;">Overrep. Sequences</a></li>
<li><a href="#tab5" style="font-size: 0.5em;">Per Base GC</a></li>
<li><a href="#tab6" style="font-size: 0.5em;">Per Base N</a></li>
<li><a href="#tab7" style="font-size: 0.5em;">Per base seq content</a></li>
<li><a href="#tab8" style="font-size: 0.5em;">Per base seq qual</a></li>
<li><a href="#tab9" style="font-size: 0.5em;">Per Sequence GC</a></li>
<li><a href="#tab10" style="font-size: 0.5em;">Per Sequence qual</a></li>
<li><a href="#tab11" style="font-size: 0.5em;">Per tile seq. qual</a></li>
<li><a href="#tab12" style="font-size: 0.5em;">Sequence Dup. levels</a></li>
<li><a href="#tab13" style="font-size: 0.5em;">Sequence Length Dist</a></li>
</ul>
<div id="tab1"></div>
<div id="tab2"></div>
<div id="tab3"></div>
<div id="tab4"></div>
<div id="tab5"></div>
<div id="tab6"></div>
<div id="tab7"></div>
<div id="tab8"></div>
<div id="tab9"></div>
<div id="tab10"></div>
<div id="tab11"></div>
<div id="tab12"></div>
<div id="tab13"></div>
</div>
</div>
</div>
<script>
$("#groups").hide();
</script>
<script>
$(function(){
// turn the element to select2 select style
$('#selected-groups').select2();
});
//All Single File data structures
//Names of each file
var fileNames = [];
//Data for group visualizations
var groupData = {};
//All content from the files
var singleFileContent = [];
//Pass/Fail/Warn status for each test in the file
var PWF = [];
//File index
var fileCounter = 0;
//Number of new files added to FastQC tool
var newFile = 0;
//Select2 group selections
var selectedGroups = document.getElementById("selected-groups");
var fileNameArray = document.getElementById("slct");
var colors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
"#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
//All concatenated file data structures
var allBasicStatistics = [],
allPerBaseSequenceQuality = [],
allPerTileSequenceQuality = [],
allPerSequenceQualityScores = [],
allPerBaseSequenceContent = [],
allPerSequenceGCcontent = [],
allPerBaseNcontent = {data: [], status: []},
allSequenceLengthDistribution = [],
allSequenceDuplicationLevels = [],
allOverrepresentedSequences = [],
allAdapterContent = {data: [], filenames: []},
allKmerContent = [];
var singleFileImages = {
pass: "http://cliparts.co/cliparts/8ix/noy/8ixnoyj8T.png",
fail: "http://www.clker.com/cliparts/a/T/A/y/b/C/x-mark-hi.png",
warn: "https://pixabay.com/static/uploads/photo/2014/04/03/00/29/exclamation-mark-308416_960_720.png",
unknown: "http://www.landsbygdsnatverket.se/images/18.765a35dc13f7d0bf7c424b7/1372688013775/Fr%C3%A5getecken.png"
};
function readFile(files) {
for (var i = 0; i < files.length; i++) {
(function (file) {
var reader = new FileReader();
reader.onload = function (e) {
var text = e.target.result;
whenLoaded(text);
};
reader.readAsText(file, "UTF-8");
})(files[i]);
}
}
function whenLoaded(text) {
if (newFile === 0) {
console.time('#test');
}
if (fileCounter === 0) {
allPerBaseNcontentStatus = [];
}
var fileArray = text.split("\n");
var name = fileArray[3].replace("Filename", "").trim();
newFile = newFile + 1;
if (fileNames.indexOf(name) === -1) {
var modules = qcCreateDictionary(fileArray);
PWF[fileCounter] = modules[1];
modules = modules[0];
fileNames[fileCounter] = name;
singleFileContent[fileCounter] = modules;
allBasicStatistics = allBasicStatistics.concat(modules["BasicStatistics"]);
allPerBaseSequenceQuality = allPerBaseSequenceQuality.concat(modules["Perbasesequencequality"].slice(2));
// allPerTileSequenceQuality = allPerTileSequenceQuality.concat(modules["Pertilesequencequality"]);
allPerSequenceQualityScores = allPerSequenceQualityScores.concat(modules["Persequencequalityscores"]);
// allPerBaseSequenceContent = allPerBaseSequenceContent.concat(modules["Perbasesequencecontent"]);
// allPerSequenceGCcontent = allPerSequenceGCcontent.concat(modules["PersequenceGCcontent"]);
if (modules["PerbaseNcontent"][0] !== "pass") {
allPerBaseNcontent.data = allPerBaseNcontent["data"]
.concat(modules["PerbaseNcontent"]
.slice(2).join(",")
.replace(/\s+/g, " ")
.split(","));
allPerBaseNcontent.status = allPerBaseNcontent["status"].concat(modules["PerbaseNcontent"][0]);
}
// allSequenceLengthDistribution = allSequenceLengthDistribution.concat(modules["SequenceLengthDistribution"]);
if (modules["SequenceDuplicationLevels"][0] === "warn" || modules["SequenceDuplicationLevels"][0] === "fail") {
allSequenceDuplicationLevels.push({
percent: Math.round(modules.SequenceDuplicationLevels[3].replace(/\s+/g, " ").split(" ")[1]),
status: modules.SequenceDuplicationLevels[0]
});
}
// allOverrepresentedSequences = allOverrepresentedSequences.concat(modules["Overrepresentedsequences"]);
if (modules.AdapterContent !== undefined) {
var adapterContent = modules["AdapterContent"][1].split("\t").slice(1);
allAdapterContent.data = allAdapterContent.data.concat(adapterContent);
allAdapterContent.filenames = allAdapterContent.filenames
.concat(Array(adapterContent.length+1).join(name+" ")
.split(" ").splice(0,adapterContent.length));
}
else {
allAdapterContent.data = allAdapterContent.data.concat(["None"]);
allAdapterContent.filenames.push(name);
}
// allKmerContent = allKmerContent.concat(modules["KmerContent"]);
//Populate file list
var newOption = document.createElement("option");
newOption.value = fileNames[fileCounter];
newOption.innerHTML = fileNames[fileCounter];
fileNameArray.add(newOption)
fileCounter = fileCounter + 1;
if (newFile === qcFile.files.length) {
newFile = 0;
var merged = [].concat.apply([], PWF).sort();
// Working on this prior to restarting console.log(allSequenceDuplicationLevels);
fileSelect(fileNameArray.value);
aggregateStatus(merged);
var allBasicStatsData = basicStatsData(allBasicStatistics, fileNames);
allBasicStatisticsFunctions(allBasicStatsData);
allPerBaseSeqQualFunc(allPerBaseSequenceQuality.join(",").replace(/\s+/g, " "), fileNames);
stringData(allAdapterContent.data, allAdapterContent.filenames, "nineteen", "Adapters",
"#container19", "Summary of Adapters Used", " ", "rotate(-50)",
"end", 650);
// console.log(allPerBaseSequenceQuality);
// console.log(allPerTileSequenceQuality);
allPerSequenceQualityScoreFunctions(allPerSequenceQualityScores);
// console.log(allPerSequenceQualityScores);
// console.log(allPerBaseSequenceContent);
// console.log(allPerSequenceGCcontent);
allPerBaseNcontentFunc(allPerBaseNcontent);
// console.log(allPerBaseNcontent);
// console.log(allSequenceLengthDistribution);
// console.log(allSequenceDuplicationLevels);
// console.log(allOverrepresentedSequences);
// console.log(allAdapterContent);
// console.log(allKmerContent);
console.timeEnd('#test');
}
}
}
function allPerBaseNcontentFunc(data) {
document.getElementById("twentytwo").innerHTML = "Per base N content failures and warnings";
var dataObj = {warn: new Array(), fail: new Array()};
var j = 0, bases = [], warnClick = "on", failClick = "on";
for (var i = 0; i < data.data.length; i++) {
var d = data.data[i].split(" ");
if (i !== 0 && d[0] === "1") {
j++;
}
dataObj[data.status[j]].push({
base: d[0],
percent: d[1],
filenumber: j
});
bases[i] = d[0];
}
bases = bases.unique().sort(customSort);
var failDataNest = d3.nest()
.key(function (d) {
return d.filenumber;
})
.entries(dataObj.fail);
var warnDataNest = d3.nest()
.key(function (d) {
return d.filenumber;
})
.entries(dataObj.warn);
d3.select("#container22").select("svg").remove();
var vis = d3.select("#container22").append("svg")
.attr("width", 650)
.attr("height", 550);
var warnVis = vis.append("g").attr("id", "warnVis");
var failVis = vis.append("g").attr("id", "failVis");
var yScale = d3.scale.linear().range([40, 500]).domain([100, 0]),
xScale = d3.scale.ordinal().rangePoints([40, 500]).domain(bases);
var xAxis = d3.svg.axis().scale(xScale);
var yAxis = d3.svg.axis().scale(yScale).orient("left");
var lineGen = d3.svg.line()
.x(function (d) {
return xScale(d.base);
})
.y(function (d) {
return yScale(d.percent);
});
failDataNest.forEach(function (d) {
vis.append("path")
.attr("transform", "translate(0," + 0 + ")")
.attr("fill", "none")
.attr("id", "fails")
.attr("stroke", "#ff0505")
.attr("stroke-width", 0.5)
.attr("d", lineGen(d.values));
});
warnDataNest.forEach(function (d) {
warnVis.append("path")
.attr("transform", "translate(0," + 0 + ")")
.attr("id", "warnings")
.attr("fill", "none")
.attr("stroke", "#ffc40c")
.attr("stroke-width", 0.5)
.attr("d", lineGen(d.values));
});
var warnImg = vis.append("svg:image")
.attr("xlink:href", singleFileImages.warn)
.attr("class", "pointerImage")
.attr("width", 20)
.attr("height", 20)
.attr("x", 520)
.attr("y", 40)
.on("click", function () {
if (warnClick === "on") {
d3.select(this).attr("opacity", 0.35);
vis.select("#warnText").text("off");
warnClick = "off";
d3.selectAll("#warnings").remove();
return;
}
if (warnClick === "off") {
d3.select(this).attr("opacity", 1);
vis.select("#warnText").text("on");
if (failClick === "off") {
yScale.domain([20, 0]);
vis.select(".yaxis").call(yAxis);
}
warnDataNest.forEach(function (d) {
warnVis.append("path")
.attr("transform", "translate(0," + 0 + ")")
.attr("id", "warnings")
.attr("fill", "none")
.attr("stroke", "#ffc40c")
.attr("stroke-width", 0.5)
.attr("d", lineGen(d.values));
});
warnClick = "on";
return;
}
});
var failImg = vis.append("svg:image")
.attr("xlink:href", singleFileImages.fail)
.attr("class", "pointerImage")
.attr("width", 20)
.attr("height", 20)
.attr("x", 520)
.attr("y", 65)
.on("click", function () {
if (failClick === "on") {
d3.select(this).attr("opacity", 0.35);
vis.select("#failText").text("off");
failClick = "off";
d3.selectAll("#fails").remove();
if (warnClick === "on") {
yScale.domain([20, 0]);
d3.selectAll("#warnings").remove();
vis.select(".yaxis").call(yAxis);
warnDataNest.forEach(function (d) {
warnVis.append("path")
.attr("transform", "translate(0," + 0 + ")")
.attr("id", "warnings")
.attr("fill", "none")
.attr("stroke", "#ffc40c")
.attr("stroke-width", 0.5)
.attr("d", lineGen(d.values));
});
}
return;
}
if (failClick === "off") {
d3.select(this).attr("opacity", 1);
vis.select("#failText").text("on");
yScale.domain([100, 0]);
vis.select(".yaxis").call(yAxis);
if (warnClick === "on") {
d3.selectAll("#warnings").remove();
warnDataNest.forEach(function (d) {
warnVis.append("path")
.attr("transform", "translate(0," + 0 + ")")
.attr("id", "warnings")
.attr("fill", "none")
.attr("stroke", "#ffc40c")
.attr("stroke-width", 0.5)
.attr("d", lineGen(d.values));
});
}
failDataNest.forEach(function (d) {
failVis.append("path")
.attr("transform", "translate(0," + 0 + ")")
.attr("id", "fails")
.attr("fill", "none")
.attr("stroke", "#ff0505")
.attr("stroke-width", 0.5)
.attr("d", lineGen(d.values));
});
failClick = "on";
return;
}
});
vis.append("text")
.attr("x", 270)
.attr("y", 20)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Per base N content across all bases for failures and warnings");
vis.append("text")
.attr("x", 270)
.attr("y", 540)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Position in read (bp)");
vis.append("text")
.style("text-anchor", "middle")
.attr("transform", "translate(10,270) rotate(-90)")
.attr("class", "y-axis-title")
.text("Percentage (%)");
vis.append("text")
.attr("x", 550)
.attr("y", 52)
.attr("id", "warnText")
.style("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.text("on");
vis.append("text")
.attr("x", 550)
.attr("y", 77) //+12
.attr("id", "failText")
.style("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.text("on");
vis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(0," + 500 + ")")
.call(xAxis);
vis.append("svg:g")
.attr("class", "yaxis")
.attr("transform", "translate(" + 4 + "0)")
.call(yAxis);
}
function allPerBaseSeqQualFunc(data, names) {
document.getElementById("twenty").innerHTML = "Per base sequence quality means";
document.getElementById("twentyone").innerHTML = "Per base sequence quality medians";
data = data.split(",");
var dataArray = [], base = [];
var j = 0;
for (var i = 0; i < data.length; i++) {
base[i] = data[i].split(" ")[0].split("-").pop();
if (base[i] === "1" && i !== 0) {
j++;
}
dataArray[i] = {
x: base[i],
mean: data[i].split(" ")[1],
median: data[i].split(" ")[2],
filename: names[j]
};
}
base = base.unique().sort(customSort);
var dataNest = d3.nest()
.key(function (d) {
return d.filename;
})
.entries(dataArray);
d3.select("#container20").select("svg").remove();
d3.select("#container21").select("svg").remove();
var meanVis = d3.select("#container20").append("svg")
.attr("width", 650)
.attr("height", 550);
var medianVis = d3.select("#container21").append("svg")
.attr("width", 650)
.attr("height", 550);
var mean_yMax = Math.max.apply(Math, dataArray.map(function (dataArray) {
return dataArray.mean;
}));
var median_yMax = Math.max.apply(Math, dataArray.map(function (dataArray) {
return dataArray.median;
}));
var xScale = d3.scale.ordinal().rangePoints([40, 500]).domain(base);
var mean_yScale = d3.scale.linear().range([40, 500]).domain([mean_yMax, 0]);
var median_yScale = d3.scale.linear().range([40, 500]).domain([median_yMax, 0]);
var xAxis = d3.svg.axis().scale(xScale);
var mean_yAxis = d3.svg.axis().scale(mean_yScale).orient("left");
var median_yAxis = d3.svg.axis().scale(median_yScale).orient("left");
var mean_lineGen = d3.svg.line()
.x(function (d) {
return xScale(d.x);
})
.y(function (d) {
return mean_yScale(d.mean);
});
var median_lineGen = d3.svg.line()
.x(function (d) {
return xScale(d.x);
})
.y(function (d) {
return median_yScale(d.median);
});
dataNest.forEach(function (d) {
meanVis.append("path")
.attr("transform", "translate(100," + 0 + ")")
.attr("fill", "none")
.attr("stroke", "blue")
.attr("stroke-width", 0.5)
.attr("d", mean_lineGen(d.values));
});
dataNest.forEach(function (d) {
medianVis.append("path")
.attr("transform", "translate(100," + 0 + ")")
.attr("fill", "none")
.attr("stroke", "red")
.attr("stroke-width", 0.5)
.attr("d", median_lineGen(d.values));
});
meanVis.append("text")
.attr("x", 370)
.attr("y", 540)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Position in read (bp)");
meanVis.append("text")
.attr("x", 375)
.attr("y", 20)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Distribution of per base sequence quality means");
meanVis.append("text")
.style("text-anchor", "middle")
.attr("transform", "translate(60,270) rotate(-90)")
.attr("class", "y-axis-title")
.text("Quality");
medianVis.append("text")
.attr("x", 370)
.attr("y", 540)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Position in read (bp)");
medianVis.append("text")
.attr("x", 375)
.attr("y", 20)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Distribution of per base sequence quality medians");
medianVis.append("text")
.style("text-anchor", "middle")
.attr("transform", "translate(60,270) rotate(-90)")
.attr("class", "y-axis-title")
.text("Quality");
meanVis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(100," + 500 + ")")
.call(xAxis);
medianVis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(100," + 500 + ")")
.call(xAxis);
meanVis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(" + 14 + "0)")
.call(mean_yAxis);
medianVis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(" + 14 + "0)")
.call(median_yAxis);
}
function aggregateStatus(merged) {
document.getElementById("eightteen").innerHTML = "Module Status Summary";
var obj = {
'Adapter Content': new Array(),
'Basic Statistics': new Array(),
'Kmer Content': new Array(),
'Overrepresented sequences': new Array(),
'Per base GC content': new Array(),
'Per base N content': new Array(),
'Per base sequence content': new Array(),
'Per base sequence quality': new Array(),
'Per sequence GC content': new Array(),
'Per sequence quality scores': new Array(),
'Per tile sequence quality': new Array(),
'Sequence Duplication Levels': new Array(),
'Sequence Length Distribution': new Array()
};
for (var i = 0; i < merged.length; i++) {
obj[merged[i].slice(0, -5)].push(merged[i].slice(-4));
}
var keys = Object.keys(obj);
var len = keys.length;
var total = obj["Basic Statistics"].length;
var dataArray = [], hoverArray = [];
for (var i = 0; i < len; i++) {
var stats = obj[keys[i]];
var counts = {}, holder = [];
for (var j = 0; j < stats.length; j++) {
counts[stats[j]] = 1 + (counts[stats[j]] || 0);
}
if (counts.fail === undefined) {
counts.fail = 0;
}
if (counts.pass === undefined) {
counts.pass = 0;
}
if (counts.warn === undefined) {
counts.warn = 0;
}
counts.unknown = total - stats.length;
obj[keys[i]] = counts;
counts.passy = total;
counts.warny = total - counts.pass;
counts.faily = counts.warny - counts.warn;
counts.unknowny = counts.faily - counts.fail;
counts.x = keys[i];
holder[0] = {x: total - counts.passy,
color: "#1fee2d",
width: counts.pass,
y: keys[i]
};
holder[1] = {x: total - counts.warny,
color: "#ffc40c",
width: counts.warn,
y: keys[i]};
holder[2] = {x: total - counts.faily,
color: "#ff0505",
width: counts.fail,
y: keys[i]};
holder[3] = {x: total - counts.unknowny,
color: "#d3d3d3",
width: counts.unknown,
y: keys[i]};
hoverArray[i] = {x: 40, y: keys[i], width: 460, pass: counts.pass,
fail: counts.fail, warn: counts.warn, unknown: counts.unknown};
dataArray[i] = holder;
}
var merged = [].concat.apply([], dataArray);
keys.unshift("");
keys.push(" ");
d3.select("#container18").select("svg").remove();
var vis = d3.select("#container18").append("svg")
.attr("width", 800)
.attr("height", 550);
var xScale = d3.scale.linear().range([40, 500]).domain([0, total]);
var yScale = d3.scale.ordinal().rangePoints([40, 500]).domain(keys);
var xAxis = d3.svg.axis().scale(xScale);
var yAxis = d3.svg.axis().scale(yScale).orient("left");
var h = (460 / 14) * 0.8;
var rects = vis.append("g");
var images = vis.append("g");
var text = vis.append("g");
rects.selectAll("rects")
.data(merged)
.enter()
.append("rect")
.attr("y", function (d) {
return yScale(d.y) - (h / 2);
})
.attr("x", function (d) {
return xScale(d.x);
})
.attr("width", function (d) {
return xScale(d.width) - 40;
})
.attr("height", h)
.attr("fill", function (d) {
return d.color;
});
var hoverRect = rects.selectAll("hovers")
.data(hoverArray)
.enter()
.append("rect")
.attr("x", function (d) {
return d.x;
})
.attr("y", function (d) {
return yScale(d.y) - (h / 2);
})
.attr("width", function (d) {
return d.width;
})
.attr("height", h)
.attr("fill", "white")
.attr("fill-opacity", 0.1)
.attr("stroke", "black")
.attr("stroke-width", 2)
.on("mouseover", function (d) {
text.append("text")
.attr("x", 650)
.attr("y", 52)
.attr("text-anchor", "start")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.attr("fill", "black")
.text(d.pass);
text.append("text")
.attr("x", 650)
.attr("y", 77)
.attr("text-anchor", "start")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.attr("fill", "black")
.text(d.warn);
text.append("text")
.attr("x", 650)
.attr("y", 102)
.attr("text-anchor", "start")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.attr("fill", "black")
.text(d.fail);
text.append("text")
.attr("x", 650)
.attr("y", 127)
.attr("text-anchor", "start")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.attr("fill", "black")
.text(d.unknown);
d3.select(this)
.attr("stroke", "blue")
.attr("stroke-width", 3.5);
})
.on("mouseout", function (d) {
text.selectAll("*").remove();
d3.select(this)
.attr("stroke", "black")
.attr("stroke-width", 2);
});
var passImg = images.append("svg:image")
.attr("xlink:href", singleFileImages.pass)
.attr("width", 20)
.attr("height", 20)
.attr("x", 620)
.attr("y", 40);
var warnImg = images.append("svg:image")
.attr("xlink:href", singleFileImages.warn)
.attr("width", 20)
.attr("height", 20)
.attr("x", 620)
.attr("y", 65);
var failImg = images.append("svg:image")
.attr("xlink:href", singleFileImages.fail)
.attr("width", 20)
.attr("height", 20)
.attr("x", 620)
.attr("y", 90);
var unknownImg = images.append("svg:image")
.attr("xlink:href", singleFileImages.unknown)
.attr("width", 23)
.attr("height", 23)
.attr("x", 620)
.attr("y", 115);
vis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(110, 500)")
.call(xAxis);
vis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(150,0)")
.call(yAxis);
vis.append("text")
.style("text-anchor", "middle")
.attr("transform", "translate(10,270) rotate(-90)")
.attr("class", "y-axis-title")
.text("Modules");
vis.append("text")
.attr("x", 270)
.attr("y", 530)
.attr("class", "x-axis-title")
.attr("transform", "translate(110, 0)")
.style("text-anchor", "middle")
.text("# of Files");
vis.append("text")
.attr("x", 270)
.attr("y", 20)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Pass/Warn/Fail/Unknown per module");
vis.select("g").attr("transform", "translate(110,0)");
}
function allPerSequenceQualityScoreFunctions(data) {
document.getElementById("seventeen").innerHTML = "Distribution of per sequence quality scores";
var dataArray = [];
var splitText, file = 0;
for (var i = 0; i < data.length; i++) {
splitText = data[i].replace(/\s+/g, ' ').split(" ");
if (isNaN(splitText[0]) === false) {
dataArray.push({
quality: splitText[0],
count: splitText[1],
filename: fileNames[file]
});
}
if (isNaN(splitText[0]) === true && i > 1) {
i = i + 2;
file++;
}
}
var dataNest = d3.nest()
.key(function (d) {
return d.filename;
})
.entries(dataArray);
d3.select("#container17").select("svg").remove();
var vis = d3.select("#container17").append("svg")
.attr("width", 650)
.attr("height", 550);
var yMax = Math.max.apply(Math, dataArray.map(function (dataArray) {
return dataArray.count;
}));
var xMax = Math.max.apply(Math, dataArray.map(function (dataArray) {
return dataArray.quality;
}));
var xScale = d3.scale.linear().range([40, 500]).domain([0, (xMax + 1)]);
var yScale = d3.scale.linear().range([40, 500]).domain([yMax, 0]);
var xAxis = d3.svg.axis().scale(xScale);
var yAxis = d3.svg.axis().scale(yScale).orient("left");
var lineGen = d3.svg.line()
.x(function (d) {
return xScale(d.quality);
})
.y(function (d) {
return yScale(d.count);
});
dataNest.forEach(function (d) {
vis.append("path")
.attr("transform", "translate(100," + 0 + ")")
.attr("fill", "none")
.attr("stroke", "grey")
.attr("stroke-width", 1)
.attr("d", lineGen(d.values));
});
vis.append("text")
.attr("x", 370)
.attr("y", 540)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Mean Sequence Quality (Phred Score)");
vis.append("text")
.attr("x", 375)
.attr("y", 20)
.attr("class", "x-axis-title")
.style("text-anchor", "middle")
.text("Quality score distribution over all sequences");
vis.append("text")
.style("text-anchor", "middle")
.attr("transform", "translate(60,270) rotate(-90)")
.attr("class", "y-axis-title")
.text("Count");
vis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(100," + 500 + ")")
.call(xAxis);
vis.append("svg:g")
.attr("class", "axis")
.attr("transform", "translate(" + 14 + "0)")
.call(yAxis);
}
function basicStatsData(array, filenames) {
var obj = {
filetype: new Array(),
encoding: new Array(),
totalSequences: new Array(),
sequenceLength: new Array(),
GC: new Array()
};
for (var i = 0; i < array.length; i++) {
if (array[i].includes("File type") === true) {
obj.filetype.push(array[i].replace("File type", "").trim());
}
if (array[i].includes("Encoding") === true) {
obj.encoding.push(array[i].replace("Encoding", "").trim());
}
if (array[i].includes("Total Sequences") === true) {
obj.totalSequences.push(array[i].replace("Total Sequences", "").trim());
}
if (array[i].includes("Sequence length") === true) {
obj.sequenceLength.push(array[i].replace("Sequence length", "").trim());
}
if (array[i].includes("GC") === true) {
obj.GC.push(array[i].replace("%GC", "").trim());
}
}
obj.filenames = filenames;
return obj;
}
function allBasicStatisticsFunctions(data) {
stringData(data.filetype, data.filenames, "thirteen", "File types", "#container13",
"Distribution of file types", "File type", "rotate(0)", "middle", 550);
stringData(data.encoding, data.filenames, "fourteen", "Encoding types", "#container14",
"Distribution of encoding types", "Encoding type", "rotate(0)", "middle", 550);
totalsequences(data.totalSequences);
GCcontents(data.GC);
}
function GCcontents(data) {
document.getElementById("sixteen").innerHTML = "Distribution of GC content";
var categories = ["0", "1-5", "6-10", "11-15", "16-20", "21-25", "26-30", "31-35",
"36-40", "41-45", "46-50", "51-55", "56-60", "61-65", "66-70", "71-75", "76-80",
"81-85", "86-90", "91-95", "96-100", ""];
var GCdata = [];
for (var i = 0; i < data.length; i++) {
if (data[i] >= 1 && data[i] < 6) {
GCdata[i] = "1-5";
}
else if (data[i] >= 6 && data[i] < 11) {
GCdata[i] = "6-10";
}