-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1073 lines (973 loc) · 39.6 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>
<meta charset="utf-8">
<html>
<head>
<title>Ancestral and offspring nutrition interact to affect life history traits in Drosophila melanogaster</title>
<style>
rect.bordered {
stroke: #E6E6E6;
stroke-width:2px;
}
text.mono {
font-size: 9.5pt;
font-family: Consolas, courier;
fill: #aaa;
}
text.legmono {
font-size: 11pt;
font-family: Consolas, courier;
fill: #aaa;
}
text.axis-workweek {
fill: #000;
}
text.axis-worktime {
fill: #000;
}
/*
.vertical-text {
transform: rotate(90deg);
transform-origin: left top 0;
}*/
body {
background-color: #FAF7F7 !important; /*Optional*/
}
footer {
text-align: center;
padding: 10px;
}
.leftColumn
{
width: 50%;
margin: 0 auto;
/*display: inline;*/
float:left;
/*width: 100%; /*Optional*/
/*table-layout: fixed; /*Optional*/
/*border-spacing: 10px; /*Optional*/
}
.rightColumn
{
width: 50%;
/*max-width: 50%;*/
float: left;
/*display: flex-shrink;*/
}
@media only screen and (max-width: 629px) {
/* for widths less than or equal to 629 pixels */
.leftColumn {
float: none ;
width: 100% ;
}
.rightColumn{
float: none ;
width: 100% ;
}
}
.Row
{
width: 100%;
}
.filters {
display: flex;
padding: 10px;
}
.filter-block {
padding: 10px;
}
#legendBlock {
width: 20px;
height: 20px;
}
div.legblock1 {
background-color: rgb(8, 29, 88);
}
div.legblock2 {
background-color: rgb(37, 52, 148);
}
div.legblock3 {
background-color: rgb(29, 145, 192);
}
div.legblock4 {
background-color: rgb(65, 182, 196);
}
div.legblock5 {
background-color: rgb(255, 255, 217);
}
div.tooltipheatmap {
position: absolute;
text-align: center;
/*width: 155px;*/
/*height: 60px;*/
padding: 6px;
font: 12px sans-serif;
background: lightsteelblue;
border: 0px;
border-radius: 2px;
pointer-events: none;
}
div.tooltip {
display: none;
}
.row.vdivide [class*='col-']:not(:last-child):after {
background: #e0e0e0;
width: 1px;
content: "";
display:block;
position: absolute;
top:0;
bottom: 0;
right: 0;
min-height: 70px;
}
.vspace {
padding-left: 15px;
margin-bottom: 10px;
}
</style>
<script src="https://d3js.org/d3.v3.js"></script>
<!-- <script src="https://code.jquery.com/jquery-1.10.2.js"></script> -->
<link rel="stylesheet" type="text/css" href="distrochart.css">
<!-- Latest compiled and minified CSS -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
<!-- Optional theme -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> -->
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
<script src="js/bootstrap.min.js"></script>
<div class="container-fluid">
<div class='row'>
<div class='col-md-10 col-md-offset-1 col-xs-10 col-xs-offset-1'>
<center>
<h1>Ancestral and offspring nutrition interact to affect life history traits in <i>Drosophila melanogaster</i></h1>
<p>
Research design and data collection by <label>Joe Deas</label><sup>1</sup>;
Data-visualization by <label>Leo Blondel</label><sup>2</sup>;
Principal Investigator <label>Cassandra G Extavour</label><sup>1,2</sup>
</p>
<p>
1: Department of Organismic and Evolutionary Biology, Harvard University. <br />
2: Department of Molecular and Cellular Biology, Harvard University.
</p>
<p>
<i>Ancestral environmental conditions can impact descendant phenotypes through a variety of epigenetic mechanisms. Previous studies on transgenerational effects in Drosophila melanogaster suggest that parental nutrition may affect the body size, development time, and eggsize of the next generation. However, it is unknown whether these effects on phenotype remain stable across generations, or if specific generations have general responses to ancestral diet. In the current study, we examine the effect on multiple life history phenotypes of changing diet treatments across three generations. All phenotypes were strongly affected by poor diet, but only certain phenotypes showed patterns of transgenerational effects. Our analysis revealed unforeseen patterns in how phenotypes respond to dietary restriction. Multiple forms of linear regression modeling show that when considering only two generations, offspring phenotypes are primarily affected by the diet they eat, and to a lesser extent, the diet of their parents, and interactions between the two diets. Surprisingly, however, when considering three generations, offspring phenotypes are predominantly impacted by the diet of their grandparents and parents, and to a lesser extent, their own diet or interactions among the ancestral and descendant diets. To improve investigations into the mechanisms and consequences of transgenerational, epigenetic inheritance, future phenotype assays need to closely examine how phenotypes change across a higher number of generations, and should also consider responses to broader variability in diet treatments.</i>
</p>
<p>
This site provides an interactive data visualization that allows the user to explore the dataset described in (Deas et al. 2018).
The left matrix displays the results of corrected pairwise statistical comparisons (Dunn’s test) between the phenotypes of two sets
of generations of Drosophila melanogaster, each generation having been subjected to a different diet (standard (S),
rich (R) or poor (P)). To explore this dataset, you can observe on the matrix the impact of a change of diet on a given phenotype.
To the right of the matrix, you can use different filters and selectors to view different phenotypes, or ask particular
questions about the effects of different dietary combinations on phenotypes of interest. For example, you can
choose to observe the impact of a rich F0 diet, followed by a poor F1 diet, by selecting <label>"Generation Selector:
F0 Rich F1 Poor F2 Any"</label>. To obtain the raw data for a particular comparison, click on the corresponding square
in the matrix, and the raw data will be displayed in a plot at the bottom right under <i>Raw data visualization
for a given comparison.</i>
Each square in the matrix on the left is colored according to the p-value returned by the statistical test performed
between the corresponding column and row dietary combinations. The p-value is displayed by hovering over the square.
The darker the blue color, the more significant the difference is.
</p>
<p>
The raw data can be downloaded here: <a href="./dataset/dataset.zip">Dataset</a>. The documentation is in the <a href="https://github.com/extavourlab/TransgenerationalEffectOfNutrition/blob/master/dataset/README.md">README.md</a> file. The source code for this dataviz is Open-Sourced under the MIT licence, and can be found here: <a href="https://github.com/extavourlab/TransgenerationalEffectOfNutrition">Github Repository</a>.
</p>
<H3>Legend</H3>
<p>
<label>P</label>: Poor; <label>R</label>: Rich; <label>S</label>: Standard<br />
<label>XY</label>: F0 was subjected to diet X and F1 diet Y (example: PR: F0 poor and F1 rich)<br />
<label>XYZ</label>: F0 was subjected to diet X, F1 diet Y and F2 diet Z (example: SRP: F0 standard, F1 rich and F2 poor)
</p>
<p>
<div class="row">
<img src="./images/egg.svg" width='70px' title="Egg Size"/> Egg Size
<img src="./images/mass.svg" width='70px' title="Fly mass"/> Fly mass
<img src="./images/wing.svg" width='70px' title="Wing Length"/> Wing Length
<img src="./images/ovarno.svg" width='70px' title="Number of Ovariole"/> Number of Ovariole
</div>
<div class="row">
<img src="./images/L1A.svg" width='70px' title="Larvae to Adult development time"/> Larvae to Adult development time
<img src="./images/LPA.svg" width='70px' title="Pupae to Adult development time"/> Pupae to Adult development time
<img src="./images/L1LP.svg" width='70px' title="Larvae to Pupae development time"/> Larvae to Pupae development time
</div>
</p>
<p>
<div class="row">
<div id="legendBlock" class="legblock1 col-sm-1"></div>
<div id="legendBlock" class="legblock2 col-sm-1"></div>
<div id="legendBlock" class="legblock3 col-sm-1"></div>
<div id="legendBlock" class="legblock4 col-sm-1"></div>
<div id="legendBlock" class="legblock5 col-sm-1"></div>
<div>
Each square is colored by the p-value of the statistical test performed between the corresponding column and row group. The p-value is displayed by hovering over the square. The darker the blue, the more significant the difference is.
</div>
</div>
</p>
</div>
</center>
</div>
<hr />
<div class="row vdivide">
<div class="col-md-6 col-xs-12">
<h3>Impact of diet on a particular phenotype.</h3>
<div id="chart"></div>
</div>
<div class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-12 col-xs-12">
<!-- <div class="col-md-12 col-xs-12"> -->
<form action="" class="form-inline" style='padding-bottom:15px;'>
<div class='row' style='padding-left:15px;'>
<h3>Filters</h3>
</div>
<!-- <div class='row vspace'>
<label>Phenotype:</label>
<img src='./images/testing_button.png' width='600px'/>
</div> -->
<div class='row vspace'>
<div class="form-group">
<label>Phenotype</label>
<img src="./images/egg.svg" width='100px' id="imgegg" title="Egg Size" onclick="ChangePhenotype('eggsize')"/>
<img src="./images/mass_g.svg" width='100px' id="imgmass" title="Fly mass" onclick="ChangePhenotype('mass')"/>
<img src="./images/wing_g.svg" width='100px' id="imgwing" title="Wing Length" onclick="ChangePhenotype('winglength')"/>
<img src="./images/ovarno_g.svg" width='100px' id="imgovarno" title="Number of Ovariole" onclick="ChangePhenotype('ovarno')"/>
<img src="./images/L1A_g.svg" width='100px' id="imgL1A" title="Larvae to Adult development time" onclick="ChangePhenotype('devL1A')"/>
<img src="./images/LPA_g.svg" width='100px' id="imgLPA" title="Pupae to Adult development time" onclick="ChangePhenotype('devLPA')"/>
<img src="./images/L1LP_g.svg" width='100px' id="imgL1LP" title="Larvae to Pupae development time" onclick="ChangePhenotype('devL1LP')"/>
</div>
</div>
<!-- <div class='row vspace'>
<div class="form-group">
<label>Phenotype</label>
<select id="phenotype" class="form-control">
<option value="eggsize">Egg Size</option>
<option value="mass">Fly mass</option>
<option value="ovarno">Number of Ovariole</option>
<option value="winglength">Wing Length</option>
<option value="devL1A">L1 to Adult dev time</option>
<option value="devL1LP">L1 to LP dev time</option>
<option value="devLPA">LP to Adult dev time</option>
</select>
</div>
</div> -->
<div class='row vspace'>
<div class="form-group">
<input type="radio" name="filter-select" value="hypothesis">
<label>Preset comparisons: </label>
<div class="form-group">
<select id="hypo" name="hypo" class="form-control">
<option value="f0eqf2">Effect of changing the diet of the parents</option>
<option value="f1eqf2">Effect of changing the diet of the grandparents</option>
<option value="2same">Effect of two generations of the same diet</option>
</select>
</div>
</div>
</div>
<div class='row vspace'>
<div class="form-group">
<input class="radio" type="radio" name="filter-select" value="generations">
<label>Generation Selector: </label>
<div class="form-group">
<label>F0</label>
<select id="F0" name="F0" class="form-control">
<option value="A">Any</option>
<option value="P">Poor</option>
<option value="R">Rich</option>
<option value="N">None</option>
</select>
</div>
<div class="form-group">
<label>F1</label>
<select id="F1" name="F1" class="form-control">
<option value="A">Any</option>
<option value="S">Standard</option>
<option value="P">Poor</option>
<option value="R">Rich</option>
<option value="N">None</option>
</select>
</div>
<div class="form-group">
<label>F2</label>
<select id="F2" name="F2" class="form-control">
<option value="A">Any</option>
<option value="S">Standard</option>
<option value="P">Poor</option>
<option value="R">Rich</option>
<!-- <option value="N">None</option> -->
</select>
</div>
</div>
</div>
<div class='row vspace'>
<div class="form-group">
<input type="radio" name="filter-select" value="equals">
<label>Relationship between generational diets: </label>
<div class="form-group">
<label>F0</label>
<select id="F0-F1-equal" name="F0F1-equal" class="form-control">
<option value="not">any relationship to</option>
<option value="eq">is equal to</option>
<option value="neq">is different to</option>
</select>
</div>
<div class="form-group">
<label>F1</label>
<select id="F1-F2-equal" name="F1F2-equal" class="form-control">
<option value="not">any relationship to</option>
<option value="eq">is equal to</option>
<option value="neq">is different to</option>
</select>
<label>F2</label>
</div>
<div class="form-group">
and
<label>F0</label>
<select id="F0-F2-equal" name="F0F2-equal" class="form-control">
<option value="not">any relationship to</option>
<option value="eq">is equal to</option>
<option value="neq">is different to</option>
</select>
<label>F2</label>
</div>
</div>
</div>
</div>
<!-- <div class="col-md-4 col-xs-4">
<span class="align-middle">
<img id='imgpheno' src="./images/egg.svg" />
</span>
</div> -->
</div>
<hr />
<div class="row">
<div class="col-md-12 col-xs-12">
<h3>Raw data visualization for a given comparison.</h3>
<div class="chart-wrapper" id="chart-distro1"></div>
<label id="plotType" value='violin'>Chart Type: </label>
<button id="violinbutton" class="btn btn-default active" type="button" onclick="ChangePlotType('violin')">ViolinPlot</button>
<button id="boxplotbutton" class="btn btn-default" type="button" onclick="ChangePlotType('boxplot')">BoxPlot</button>
<button id="nonbutton" class="btn btn-default" type="button" onclick="ChangePlotType('none')">Raw Data</button>
</div>
</div>
</div>
</div>
</div>
<br />
<br />
<br />
<hr />
<footer>
<h4>Acknowledgements</h4>
We thank the Extavour Lab members for their creative and effective suggestions on experimental design and data analysis.
<h4>Credits</h4>
Thanks to the D3 Reusable charts project by Andrew Sielen (MIT licensed) for the swarm plots. <a href="http://bl.ocks.org/asielen/92929960988a8935d907e39e60ea8417">Source code</a> <br />
Heatmap adapted from Tom May Day/Hours heatmap (MIT license). <a href="http://bl.ocks.org/tjdecke/5558084">Source code</a>
<h4>Funding</h4>
This work was supported by NIH grant R01HD073499 to CGE and funds from Harvard University. JD was partially supported by NIH Supplement 3R01HD073499-03S1.
</footer>
<script src="distrochart.js" charset="utf-8"></script>
<script>
var phenotype = "eggsize";
$(window).resize(function(){location.reload();});
document.getElementById("plotType").value = 'violin';
$(document).ready(function(e) {
$("#F0").change(function(){
$('input[name="filter-select"]').filter('[value=generations]').prop('checked', true);
ApplyFilter();
});
$("#F1").change(function(){
$('input[name="filter-select"]').filter('[value=generations]').prop('checked', true);
ApplyFilter();
});
$("#F2").change(function(){
$('input[name="filter-select"]').filter('[value=generations]').prop('checked', true);
ApplyFilter();
});
$("#phenotype").change(function(){
ApplyFilter();
DrawSubPlot(null, null, null);
});
$("#F0-F1-equal").change(function(){
$('input[name="filter-select"]').filter('[value=equals]').prop('checked', true);
ApplyFilter();
});
$("#F1-F2-equal").change(function(){
$('input[name="filter-select"]').filter('[value=equals]').prop('checked', true);
ApplyFilter();
});
$("#F0-F2-equal").change(function(){
$('input[name="filter-select"]').filter('[value=equals]').prop('checked', true);
ApplyFilter();
});
$("#hypo").change(function(){
$('input[name="filter-select"]').filter('[value=hypothesis]').prop('checked', true);
ApplyFilter();
});
$('input[name="filter-select"]').change(function(){
ApplyFilter();
});
});
var ChangePhenotype = function (pheno) {
phenotype = pheno;
document.getElementById('imgegg').src='./images/egg_g.svg';
document.getElementById('imgmass').src='./images/mass_g.svg';
document.getElementById('imgwing').src='./images/wing_g.svg';
document.getElementById('imgovarno').src='./images/ovarno_g.svg';
document.getElementById('imgL1A').src='./images/L1A_g.svg';
document.getElementById('imgL1LP').src='./images/L1LP_g.svg';
document.getElementById('imgLPA').src='./images/LPA_g.svg';
if (pheno == 'eggsize') {
document.getElementById('imgegg').src='./images/egg.svg'
}
else if (pheno == 'mass') {
document.getElementById('imgmass').src='./images/mass.svg'
}
else if (pheno == 'winglength') {
document.getElementById('imgwing').src='./images/wing.svg'
}
else if (pheno == 'ovarno') {
document.getElementById('imgovarno').src='./images/ovarno.svg'
}
else if (pheno == 'devL1A') {
document.getElementById('imgL1A').src='./images/L1A.svg'
}
else if (pheno == 'devL1LP') {
document.getElementById('imgL1LP').src='./images/L1LP.svg'
}
else if (pheno == 'devLPA') {
document.getElementById('imgLPA').src='./images/LPA.svg'
}
ApplyFilter();
DrawSubPlot(null, null, null);
}
var ChangePlotType = function(plotType) {
if (plotType == 'violin') {
document.getElementById("plotType").value = 'violin';
$('#violinbutton').addClass('active').siblings().removeClass('active');
}
else if (plotType == 'boxplot') {
document.getElementById("plotType").value = 'boxplot';
$('#boxplotbutton').addClass('active').siblings().removeClass('active');
}
else if (plotType == 'none') {
document.getElementById("plotType").value = 'none';
$('#nonbutton').addClass('active').siblings().removeClass('active');
}
UpdateChart();
}
var ApplyFilter = function() {
// var filterF0 = 'A';
// var filterF1 = 'A';
// var filterF2 = 'A';
// var filterType == 'generations';
var filterType = $('input[name="filter-select"]:checked').val();
// console.log(filterType)
// var phenotype = document.getElementById("phenotype").value;
if (filterType == 'generations') {
var filterF0 = document.getElementById("F0").value;
var filterF1 = document.getElementById("F1").value;
var filterF2 = document.getElementById("F2").value;
}
else if (filterType == 'equals') {
var filterF0 = document.getElementById("F0-F1-equal").value;
var filterF1 = document.getElementById("F1-F2-equal").value;
var filterF2 = document.getElementById("F0-F2-equal").value;
}
else if (filterType == 'hypothesis') {
var filterF0 = document.getElementById("hypo").value;
var filterF1 = null;
var filterF2 = null;
}
else if (! filterType) {
filterType = 'generations';
var filterF0 = 'A';
var filterF1 = 'A';
var filterF2 = 'A';
}
// console.log("Selection is :")
// console.log(filterF0, filterF1, filterF2, phenotype, filterType);
heatmapChart(filterF0, filterF1, filterF2, phenotype, filterType);
};
// Initialize the plot
</script>
<script type="text/javascript">
var chart1;
var lastGen1;
var lastGen2;
var DrawSubPlot = function(gen1, gen2, pheno) {
// var element = document.getElementsByClassName("inner-wrapper");
// console.log(element);
// if(element.parentNode != null) {
// element.parentNode.removeChild(element);
// }
$('.inner-wrapper').remove();
if (! gen1 && ! gen2) {
gen1 = lastGen1;
gen2 = lastGen2;
// pheno = document.getElementById("phenotype").value;
}
else {
lastGen1 = gen1;
lastGen2 = gen2;
}
d3.tsv('rawdata.tsv', function(error, data) {
data.forEach(function (d) {d.value = +d.value;});
//console.log(data);
var newdata = [];
data.forEach(function(e) {
if (e.phenotype == phenotype) {
if (e.gen == gen1) {
newdata.push(e);
}
if (e.gen == gen2) {
newdata.push(e);
}
}
});
//console.log("NewData");
//console.log(newdata);
// var phenotype = document.getElementById("phenotype").value;
var winheight = $(window).height();
var winwidth = $(window).width();
if (winwidth < 990) {
winwidth *= 2
}
chart1 = makeDistroChart({
data:newdata,
xName:'gen',
yName:'value',
axisLabels: {xAxis: null, yAxis: 'Values'},
selector:"#chart-distro1",
chartSize:{height:winwidth/4, width:winwidth/2-100},
constrainExtremes:true});
chart1.renderBoxPlot();
chart1.renderDataPlots();
chart1.renderNotchBoxes({showNotchBox:false});
chart1.renderViolinPlot({showViolinPlot:false});
chart1.violinPlots.hide();
chart1.dataPlots.show({showPlot:true, plotType:'beeswarm',showBeanLines:false, colors:null});
chart1.notchBoxes.hide();
chart1.boxPlots.hide();
chart1.violinPlots.hide();
// if (phenotype == 'eggsize') {
chart1.notchBoxes.hide();
chart1.boxPlots.hide();
UpdateChart();
// }
//
// else {
// }
// chart1.dataPlots.change({showPlot:false,showBeanLines:false})
// chart1.dataPlots.show(
// {showBeanLines:true,
// beanWidth:15,
// showPlot:false,
// colors:['#555']});
// chart1.boxPlots.hide();
// chart1.notchBoxes.hide()
});
}
DrawSubPlot(null,null,null);
var UpdateChart = function() {
var plotType = document.getElementById("plotType").value;
// var phenotype = document.getElementById("phenotype").value;
if (phenotype == 'eggsize') {
var bdwidth = 20;
}
else if (phenotype == 'mass') {
var bdwidth = 0.35;
}
else if (phenotype == 'ovarno') {
var bdwidth = 5;
}
else if (phenotype == 'winglength') {
var bdwidth = 0.04;
}
else if (phenotype == 'devL1A') {
var bdwidth = 1.25;
}
else if (phenotype == 'devL1LP') {
var bdwidth = 1.25;
}
else if (phenotype == 'devLPA') {
var bdwidth = 1.25;
}
if (plotType == 'violin'){
chart1.notchBoxes.hide();
chart1.boxPlots.hide();
chart1.violinPlots.show(
{reset:true,
// width:75,
clamp:0,
// resolution:5,
bandwidth:bdwidth
});
}
else if (plotType == 'boxplot') {
chart1.violinPlots.hide();
chart1.notchBoxes.show({reset:true});
chart1.boxPlots.show({reset:true,
showBox:false,
showOutliers:true,
boxWidth:20,
scatterOutliers:true
});
}
else if (plotType == 'none') {
chart1.violinPlots.hide();
chart1.notchBoxes.hide();
chart1.boxPlots.hide();
}
}
</script>
<script type="text/javascript">
var winheight = $(window).height();
var winwidth = $(window).width();
if (winwidth < 990) {
winwidth *= 2
}
var margin = { top: 50, right: 0, bottom: 100, left: 30 },
width = winwidth/2 - 100 - margin.left - margin.right,
height = winwidth/2+40 - margin.top - margin.bottom,
buckets = 9,
colors = ['#081d58', '#253494', '#1d91c0', '#41b6c4', '#ffffd9', '#ffffd9'];
// alternatively colorbrewer.YlGnBu[9]
// datasets = ["matrix_data.tsv", "data2.tsv"];
var svg = d3.select("#chart").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var tsvFile = 'matrix_data.tsv';
if (!document.getElementById('tooltipheatmap')) {
var div = d3.select("body").append("div")
.attr("class", "tooltipheatmap")
.attr('id','tooltipheatmap')
.style("opacity", 0.9)
.style("display",'none');
}
var heatmapChart = function(f0, f1, f2, phenotype, filterType) {
d3.tsv('matrix_data.tsv',
function(d) {
return {
gen1: d.gen1,
gen2: d.gen2,
phenotype: d.phenotype,
pvalue: +d.pvalue
};
},
function(error, data) {
// Cleaning up the heatmap to be ready to replot the new data
svg.selectAll(".verticalLabel").remove();
svg.selectAll(".horizontalLabel").remove();
svg.selectAll("text").remove();
svg.selectAll(".hour").remove();
svg.selectAll(".legend").remove();
// console.log(data);
// Defining Filter Function
var Filter = function(el1, el2) {
// console.log(el);
if (filterType == 'generations') {
if (filterGen(el1) && filterGen(el2)) {
return true;
}
return false;
}
else if (filterType == 'equals') {
if (filterEquals(el1) && filterEquals(el2)){
return true;
}
return false;
}
else if (filterType == 'hypothesis') {
if (filterHypo(el1, el2)) {
return true;
}
return false;
}
};
var filterGen = function(el) {
var test = ['N','N','N'];
var result = [false,false,false];
var selection = [f0,f1,f2];
if (el.length == 1) {
test[2] = el;
}
else if (el.length == 2) {
test[2] = el[1];
test[1] = el[0];
}
else {
test[2] = el[2];
test[1] = el[1];
test[0] = el[0];
}
for (i = 0; i < 3; i++) {
if (selection[i] != 'A') {
if (test[i] == selection[i]) {
result[i] = true;
}
}
else {
result[i] = true;
}
}
if (result.every(elem => elem == true) == true) {
// console.log(result, test);
return true;
}
else {
return false;
}
};
var filterEquals = function(el) {
// console.log(el);
var test = ['X','Y','Z'];
if (el.length == 1) {
test[2] = el;
}
else if (el.length == 2) {
test[2] = el[1];
test[1] = el[0];
}
else {
test[2] = el[2];
test[1] = el[1];
test[0] = el[0];
}
var result = [false, false, false];
// Testing F0 F1 match
if (f0 == 'eq') {
if (test[0] == test[1]) {
result[0] = true;
}
}
else if (f0 == 'neq') {
if (test[0] != test[1]) {
result[0] = true;
}
}
else if (f0 == 'not') {
result[0] = true;
}
// Testing F1 F2 match
if (f1 == 'eq') {
if (test[1] == test[2]) {
result[1] = true;
}
}
else if (f1 == 'neq') {
if (test[1] != test[2]) {
result[1] = true;
}
}
else if (f1 == 'not') {
result[1] = true;
}
// Testing F0 F2 match
if (f2 == 'eq') {
if (test[0] == test[2]) {
result[2] = true;
}
}
else if (f2 == 'neq') {
if (test[0] != test[2]) {
result[2] = true;
}
}
else if (f2 == 'not') {
result[2] = true;
}
if (result.every(elem => elem == true) == true) {
return true;
}
else {
return false;
}
};
var filterHypo = function(el1, el2) {
// console.log(el);
var test = [['Z','X','Y'], ['X','Y','Z']];
if (el1.length == 1) {
test[0][2] = el1;
}
else if (el1.length == 2) {
test[0][2] = el1[1];
test[0][1] = el1[0];
}
else {
test[0][2] = el1[2];
test[0][1] = el1[1];
test[0][0] = el1[0];
}
if (el2.length == 1) {
test[1][2] = el2;
}
else if (el2.length == 2) {
test[1][2] = el2[1];
test[1][1] = el2[0];
}
else {
test[1][2] = el2[2];
test[1][1] = el2[1];
test[1][0] = el2[0];
}
var result = false;
//console.log(f0);
// Testing F0 F1 match
if (f0 == 'f0eqf2') {
// testing if F0 and F2 diet are the same
//console.log('test');
// console.log(test);
if (test[0][0] == test[1][0] && test[0][2] == test[1][2]) {
result = true;
}
else if (test[0][0] == 'Z' && test[1][0] == 'X' && test[0][1] != 'X' && test[1][1] != 'Y' && test[0][1] != test[1][1] && test[0][2] == test[1][2])
{
result = true;
}
}
else if (f0 == 'f1eqf2') {
// Testing if F1 and F2 are the same
if (test[0][1] == test[1][1] && test[0][2] == test[1][2] && test[0][0] != 'Z' && test[1][0] != 'X') {
result = true;
}
}
else if (f0 == '2same') {
if (test[0][0] == test[1][0] && test[0][1] == test[1][1]) {
result = true;
}
}
return result;
};
// Filtering the data based on selected filters
// console.log("Filtering");
var labels = [];
var newdata = [];
data.forEach(function(el) {
// console.log(el);
if (phenotype == el.phenotype) {
if (Filter(el.gen1, el.gen2)) {
if (labels.indexOf(el.gen1) < 0) {
labels.push(el.gen1)
}
if (labels.indexOf(el.gen2) < 0) {
labels.push(el.gen2)
}
newdata.push(el);
}
}
});
//console.log(newdata);
//console.log(labels);
// verticalLabels.remove()
// horizontalLabels.remove()
var gridSize = Math.floor(width / labels.length);
var leggridSize = Math.floor(width / 11);
var legendElementWidth = leggridSize*2;
var verticalLabels = svg.selectAll(".verticalLabel")
.data(labels)
.enter().append("text")
.text(function (d) { return d; })
.attr("x", 0)
.attr("y", function (d, i) { if (labels.length <= 21) {return i * gridSize - 13;} else {return i * gridSize - 2;} })
.style("text-anchor", "end")
.attr("transform", "translate(-6," + gridSize / 1.5 + ")")
.attr("class", "dayLabel mono axis axis-workweek");
var horizontalLabels = svg.selectAll(".horizontalLabel")
.data(labels)
.enter().append("text")
.text(function(d) { return d; })
.attr("x", function(d, i) { return i * gridSize; })
.attr("y", 0)
.style("text-anchor", "end")
// .style("transform", "rotate(90deg)")
// .style("transform-origin","left top 0")
.attr("writing-mode","vertical-lr")
.attr("transform", "translate(" + gridSize / 2 + ", -3)")
.attr("class", "timeLabel mono axis axis-worktime");
svg.selectAll(".timeLabel")
.selectAll("text")
// .style("text-anchor", "end")
// .attr("dx", "-.8em")
// .attr("dy", ".15em")
.style("color", "#ff0000")
.attr("transform", "rotate(90)");
var colorScale = d3.scale.linear()
.domain([0.00001, 0.001, 0.01, 0.05, 0.051, 1])
.range(colors);
var cards = svg.selectAll(".hour")
.data(newdata, function(d) {return d.gen1+':'+d.gen2;});
cards.append("title");
cards.enter().append("rect")
.attr("x", function(d) { return (labels.indexOf(d.gen1)) * gridSize; })
.attr("y", function(d) { return (labels.indexOf(d.gen2)) * gridSize; })
.attr("rx", 4)
.attr("ry", 4)
.attr("class", "hour bordered")
.attr("width", gridSize)
.attr("height", gridSize)
.on("click", function(d){