-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.html
More file actions
430 lines (407 loc) · 19.6 KB
/
Copy pathmain.html
File metadata and controls
430 lines (407 loc) · 19.6 KB
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
<!DOCTYPE html>
<html>
<title>
Genetic Drift Visualisation Tool
</title>
<!-- CSS and JS Libraries (Start) -->
<head>
<link rel='stylesheet' type='text/css' href='css/toolStyle.css'>
<script src='libraries/jquery-3.1.1.min.js'></script>
<script src='libraries/math.min.js'></script>
<script src='libraries/Timer.js'></script>
<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
<script type='text/javascript'>
google.charts.load('current', {packages: ['corechart', 'bar', 'line', 'controls']});
</script>
</head>
<!-- CSS and JS Libraries (End) -->
<body>
<!-- Top Matter HTML (Start) -->
<div class='main' id='header'>
Genetic Drift Visualisation Tool
</div>
<ul class='toolbar'>
<li class='current' data-tab='jsBody_Output' id='dummy_Output'>Output</li>
<li data-tab='jsBody_Parameters'>Parameters</li>
<li data-tab='jsBody_About'>About</li>
</ul>
<!-- Top Matter HTML (End) -->
<!-- Output Tab HTML (Start) -->
<div class='main toolbar-content current' id='jsBody_Output'>
<div id='output_heading'>
<ul class='output_headingList'>
<li>
<span id='output_headingChild'>
Generation: <span id='output_genNum'></span>
</span>
<span class='paraMag_space'></span>
<span id='output_headingChildToo'>
F<sub>ST</sub>: <span id='output_fst'></span>
</span>
</li>
<li>
<span class='paraMag_space'></span>
Simulate next <i>n</i> generations:
<button class='output_simButton' howMany='1'>n = 1 </button>
<button class='output_simButton' howMany='10'>n = 10</button>
<button class='output_simButton' howMany='output_simInput'>n =</button>
<input id='output_simInput' type='number' min=1 max=1000>
<span class='paraMag_space'></span>
<button id='output_interrupt' disabled='true'>Stop</button>
<span class='paraMag_space'></span>
<button id='output_reset'>Reset</button>
</li>
<li>
<div id="output_progressBarContainer">
<div id="output_progressBar">
<div id="output_progressNumber">
<span id="output_progressNumberChild">0</span>%
</div>
</div>
</div>
</li>
</ul>
</div>
<div id='jsBody_Container'>
<div id='output_L'>
<ul class='output_ulL'>
<li class='current' data-tab='output_alleleFreqChart'>Allele Frequencies</li>
<li data-tab='output_indivAlleleContainer'>Individual Alleles</li>
</ul>
<div class='output_chartContainer'>
<div class='output_chartDim current' id='output_alleleFreqChart'></div>
<div class='output_chartDim' id='output_indivAlleleContainer'>
<canvas class='output_indivAlleleChart' id='output_iacForeground'></canvas>
<canvas class='output_indivAlleleChart' id='output_iacMidground'></canvas>
<canvas class='output_indivAlleleChart' id='output_iacBackground'></canvas>
</div>
</div>
</div>
<div id='output_R'>
<ul class='output_ulR'>
<li class='current' data-tab='output_fstDashboard'>Conancestry Coefficient</li>
<li data-tab='output_alleleFreqChartToo'>Allele Frequencies</li>
</ul>
<div class='output_chartContainerToo'>
<div class='output_chartDimToo current' id='output_fstDashboard'>
<div id='output_fstChart'></div>
<div id='output_fstControl'></div>
</div>
<div class='output_chartDimToo' id='output_alleleFreqChartToo'>
</div>
</div>
</div>
</div>
<div id='output_curParaMagContainer'>
Current Parameters:
<ul class='output_curParaMag'>
<li>Number of Populations: <span id='output_numOfPop'></span></li>
<li>Population Size: <span id='output_popSize'></span></li>
<li>Number of Allele Types: <span id='output_numOfAlleles'></span></li>
<li>Mutation Denominator: <span id='output_mutaDenom'></span></li>
<li>Number of Migrants: <span id='output_numOfMigrants'></span></li>
<li>Initial Number of Simulations: <span id='output_init'></span></li>
<li>Simulation Rate: <span id='output_simRate'></span></li>
</ul>
</div>
</div>
<!-- Output Tab HTML (End) -->
<!-- Parameters Tab HTML (Start) -->
<div class='main toolbar-content' id='jsBody_Parameters'>
<div id='jsBody_Container'>
<ul class='paraMag' id='paraMag_L'>
<li>
Number of Populations: <input id='paraMag_numOfPop' type='number' min=1 max=10> <br>
<span class='paraMag_Info'>
Sets the number of populations to observe in the simulation routine. <br> Takes an integer value between 1 and 10 (inclusive).
</span>
</li>
<li>
Population Size: <input id='paraMag_popSize' type='number' min=50 max=500> <br>
<span class='paraMag_Info'>
Sets a population's <b>fixed</b> size in the simulation routine. Takes an integer value between 50 and 500 (inclusive).
</span>
</li>
<li>
Number of Allele Types: <input id='paraMag_numOfAlleles' type='number' min=2 max=8> <br>
<span class='paraMag_Info'>
Sets and limits the number of possible allele types in a population. Takes an integer value between 2 and 8 (inclusive).
</span>
</li>
<li>
Mutation Denominator: <input id='paraMag_mutaDenom' type='number' min=0 max=1000> <br>
<span class='paraMag_space'></span><input class='paraMag_slider' id='paraMag_mutaDenomChild' type='range' min=0 max=1000 step=1> <br>
<span class='paraMag_Info'>
Sets the denominator of an allele's mutation rate. An allele currently has <br> <span id='paraMag_mutaDenomChildToo'></span> chance to mutate into a different allele type. Takes an integer <br> value between 1 and 1000 (inclusive).
</span>
</li>
<li>
Number of Migrants: <input id='paraMag_numOfMigrants' type='number' min=0 max=499> <br>
<span class='paraMag_Info'>
Sets the number of members who migrate each generation. Takes an integer value between 0 and <span id='paraMag_numOfMigrantsChild'></span> (inclusive).
</span>
</li>
<li>
Initial Number of Simulations: <input id='paraMag_init' type='number' min=1 max=1000> <br>
<span class='paraMag_Info'>
Sets the number of simulations to conduct before the user can interact with the <b>Output</b> page. Takes an integer value between 1 and 1000 (inclusive).
</span>
</li>
<li>
Simulation Rate: <input id='paraMag_simRate' type='number' min=0.01 max=2 step=0.01> <br>
<span class='paraMag_space'></span><input id='paraMag_simRateChild' type='range' min=0.01 max=2 step=0.01> <br>
<span class='paraMag_Info'>
Sets the timer rate of executing consecutive simulations. The user interruption button will be more responsive if the Simulation Rate is set to a high value. Takes a value between 0.01 and 2.00 seconds (inclusive).
</span>
</li>
</ul>
<ul class='paraMag' id='paraMag_R'>
<li>
<button id='paraMag_submit'>Submit Parameters</button> <br>
</li>
<li id='small'>
<input id='paraMag_show' type='checkbox'>Show detailed information
</li>
</ul>
</div>
</div>
<!-- Parameters Tab HTML (Start) -->
<!-- About Tab HTML (Start) -->
<div class='main toolbar-content' id='jsBody_About'>
F<sub>ST</sub> is a useful statistic for summarising the observed genetic drift for a group of populations (Weir, 1996). F<sub>ST</sub>
is defined to be a value between 0 and 1 (inclusive). A small value of F<sub>ST</sub> proposes that the individuals
in the same subpopulation are not very related to each other. A high value of F<sub>ST</sub> suggests that individuals in the same
subpopulation are quite related to each other. We estimate F<sub>ST</sub> using an analysis of variance framework. Hence, F<sub>ST</sub>
can produce a negative estimate, which is out of the bounds of because an unbiased estimator is used to estimate F<sub>ST</sub>. But,
the size of the bias is quite minute, and F<sub>ST</sub> is only imprecise when the true F<sub>ST</sub> is exceptionally close to zero.
There is also a case when F<sub>ST</sub> is a ratio of zeroes. The phenomenon occurs when the same allele is present in all populations.
Hence, for this particular event, F<sub>ST</sub> is defined to be equal to one because the observed populations are in fact inbred,
just not in the expected fashion.
<br>
<br>
<span id='small'>
Weir, B. S. (1996). Genetic data analysis II. methods for discrete population genetic
data. Sinauer Associates, Inc. Publishers.
</span>
<hr>
The mutation scheme used was based on the stepwise mutation model proposed
by Kimura & Ohta (1978), with a minor modication to respect the
boundaries. For example, there are ve possible alleles in a population, Alleles
A, B, C, D, and E. Allele B can mutate to either Allele A or Allele C,
and a similar process applies to Allele D, and Allele E. However, Allele A and
Allele E can only mutate to Allele B and Allele D, respectively.
<br>
<br>
<span id='small'>
Kimura, M., & Ohta, T. (1978). Stepwise mutation model and distribution of
allelic frequencies in a finite population. Proceedings of the National Academy of
Sciences, 75(6), 2868–2872.
</span>
<hr>
The migration scheme used simple random sampling to select a xed number
of migrants from each of the populations. These migrants then immigrated
to a randomly chosen population, excluding their population of origin. As a
result, populations before breeding were not necessarily the specied population
size. However, this simple scheme was computationally quick to execute
as there are no constraints to enforce. Since the end users are typically going
to be students, implementing a more complex migration scheme that might
signicantly increase the simulation time could frustrate the end user.
<hr>
Libraries and resources used for this web application include:
<ul>
<li>ColorBrewer from <a href='http://colorbrewer2.org/'>colorbrewer2.org/</a>.</li>
<li>Google Charts API from <a href='https://developers.google.com/chart/'>developers.google.com/chart/</a>.</li>
<li>jQuery from <a href='https://jquery.com'>jquery.com</a>.</li>
<li>Math.js from <a href='http://mathjs.org'>mathjs.org</a>.</li>
<li>Timer.js from <a href='https://github.com/fschaefer/Timer.js'>github.com/fschaefer/Timer.js</a>.</li>
</ul>
</div>
<!-- About Tab HTML (End) -->
<!-- Bottom Matter HTML (Start) -->
<div class='main' id='copyright'>
Genetic Drift Visualisation Tool ver 0.3.0 <br>
© 2016-2017 David Chan
</div>
<!-- Bottom Matter HTML (End) -->
<!-- Initialisation of JS Functionality (Start) -->
<script src='scripts/main.js'></script>
<script src='scripts/parameters.js'></script>
<script src='scripts/output.js'></script>
<script src='scripts/indivAllele.js'></script>
<script>
var parameters = {
// Parameters Tab.
numOfPop: 5, // Number of Populations.
popSize: 50, // Population Size.
numOfAlleles: 8, // Number of Allele Types.
mutationDenom: 300, // Mutation Denom.
numOfMigrants: 0, // Number of Migrants.
init: 1, // Initial Number of Simulations.
simRate: 10, // Simulation Rate.
// Output Tab.
simInput: 100 // Number of simulations to do consecutively.
},
alleles = new allelePool(), // Stores the allelePool object and it's methods.
rngBin = new randomBinary(), // Stores the binary random number generator object.
allSpecies = [], // Stores the simulation routine.
webpageLive = false, // Tracks whether the webpage has been loaded already.
timerVars = {
// Stores the timer variables to get Javascript thinking in more than one thread.
toGenNum: 0, // Tracks how many generations to process for the
// simulation routine.
toStop: false, // Tracks whether the user has interrupted the simulation
// routine.
tickTock: new Timer(10), // The timer object.
increment: 0, // How much to increment the progress bar by.
progress: 0, // Current state of the progress bar.
progressMax: parseInt( // Parse the CSS field for how wide the progress bar is.
$('#output_progressBarContainer').css('width'), 10
)
},
scope = {
// Object variable to hold constants for fstCalc().
//ni: n_i,
//twoNi: 2*n_i,
//nBar: (n_1 + n_2 + . . . + n_r)/r,
//a: nBar - 1,
//b: (r - 1)/1,
//c: rp*(nBar - 1),
//d: r*(nBar - nC)/nBar,
//e: (nBar - 1) + (r - 1)*(nBar - nC),
//f: (nBar - nC)/(4*nC^2)
//g: n_1 + n_2 + . . . + n_r,
//h: (r - 1)*nBar
// Where r: parameters.numOfPop,
// and nC: (n_1 + . . . + n_r - [n_1^2 + . . . + n_r^2]/[n_1 + . . . + n_r])/(r - 1).
},
alleleFreq = {
// Chart options for visualising the allele frequencies.
options: {
title: 'Allele Frequencies (Parent Generation)',
height: 500,
width: 600,
bar: {
groupWidth: '70%'
},
hAxis: {
title: 'Population'
},
vAxis: {
title: 'Allele Frequency (%)',
minValue: 0,
maxValue: 1
},
isStacked: 'percent',
animation: {
duration: 1000, // in milliseconds
easing: 'out'
},
tooltip: {
isHtml: true
}
}
//data: new google.visualization.DataTable(), // Stores the allele frequencies.
//chart: new google.visualization.ColumnChart(), // The chart object.
//view: new google.visualization.DataView() // The view of the datatable object to
// visualise.
},
fst = {
// Chart options for visualising the conancestry coefficient.
optionsChart: {
title: 'Coancestry Coefficient over Generations',
height: 450,
width: 500,
hAxis: {
title: 'Generation',
minValue: 1,
gridlines: {
count: 5
}
},
vAxis: {
title: 'Coancestry Coefficient (FST)',
viewWindowMode: 'pretty',
},
legend: {
position: 'none'
},
animation: {
duration: 1000, // in milliseconds
easing: 'out'
},
tooltip: {
isHtml: true
}
},
optionsControl: {
filterColumnIndex: 0,
ui: {
chartOptions: {
height: 50,
width: 500
},
snapToData: true
}
}
//data: new google.visualization.DataTable(), // Stores the conancestry coefficient.
//chart: new google.visualization.ChartWrapper(), // The chart object.
//view: new google.visualization.DataView(), // The view of the datatable object to
// visualise.
//control: google.visualization.ControlWrapper(), // The controls object.
//dashboard: new google.visualization.Dashboard() // The dashboard instance which stores
// the chart and control objects.
},
indivAllele = {
options: {
title: 'Individual Alleles (Parent Generation)',
backgroundColor: 'white',
height: 500,
width: 600
},
tickTock: new Timer(100)
//data: new google.visualization.DataTable(), // The data table object.
//chart: new indivAlleleChart(background, midground, foreground) // The chart object which is made
// up of three <canvas>s.
},
alleleFreqChild = {
// Chart options for visualising the allele frequencies.
options: {
title: 'Allele Frequencies (Child Generation)',
height: 500,
width: 500,
bar: {
groupWidth: '70%'
},
hAxis: {
title: 'Population'
},
vAxis: {
title: 'Allele Frequency (%)',
minValue: 0,
maxValue: 1
},
isStacked: 'percent',
animation: {
duration: 1000, // in milliseconds
easing: 'out'
},
tooltip: {
isHtml: true
}
}
//data: new google.visualization.DataTable(), // Stores the allele frequencies.
//chart: new google.visualization.ColumnChart(), // The chart object.
//view: new google.visualization.DataView() // The view of the datatable object to
// visualise.
};
paraMag_submit.prop('disabled', true);
output_reset.prop('disabled', true);
output_simButtons.prop('disabled', true);
output_genNum.html('. . .');
output_fst.html('. . .');
parameters_Initialise();
google.charts.setOnLoadCallback(output_Initialise);
</script>
<!-- Initialisation of JS Functionality (End) -->
</body>
</html>