Skip to content

Commit d768b80

Browse files
Courssumm02Courssumm02
authored andcommitted
Startd M5
1 parent ed42d02 commit d768b80

File tree

4 files changed

+158
-1
lines changed

4 files changed

+158
-1
lines changed

Module 4/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var a1_data = {
3636
lineTension: 0.5,
3737
fill: false,
3838
borderColor: 'red',
39-
borderWidth: 1.5
39+
borderWidth: 0.8
4040
}
4141
var a2_data = {
4242
label: "A2",

Module 5/app.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
const N_CLONES = 100
2+
const a1_prob = 0.5
3+
const a2_prob = 1 - a1_prob
4+
const N_GEN = 10
5+
6+
const gridx = Math.round(Math.sqrt(N_CLONES)) * Math.round(Math.sqrt(N_CLONES))==N_CLONES?Math.round(Math.sqrt(N_CLONES)) : Math.round(Math.sqrt(N_CLONES))+1
7+
const gridy = Math.round(Math.sqrt(N_CLONES)) * Math.round(Math.sqrt(N_CLONES))==N_CLONES?Math.round(Math.sqrt(N_CLONES)) : Math.round(Math.sqrt(N_CLONES))+1
8+
9+
var grid = [...Array(gridx*gridy).keys()]
10+
console.log(JSON.stringify(grid));
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+
// var ctx = document.getElementById('myChart').getContext('2d');
72+
73+
74+
// var a1_data = {
75+
// label: "A1",
76+
// data: arr_a1,
77+
// lineTension: 0.5,
78+
// fill: false,
79+
// borderColor: 'red',
80+
// borderWidth: 0.8
81+
// }
82+
// var a2_data = {
83+
// label: "A2",
84+
// data: arr_a2,
85+
// lineTension: 0.5,
86+
// fill: false,
87+
// borderColor: 'blue',
88+
// borderWidth: 1.5
89+
// }
90+
91+
// const data = {
92+
// labels: [...Array(gen).keys()],
93+
// datasets: [a1_data, a2_data]
94+
// };
95+
96+
97+
// var myChart = new Chart(ctx, {
98+
// type: 'line',
99+
// data: data,
100+
// options: {
101+
// scales: {
102+
// y: {
103+
// beginAtZero: true
104+
// }
105+
// },
106+
// bezierCurve: true
107+
// }
108+
// });
109+
// myChart.update()
110+
// }

Module 5/main.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
<script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js'></script>
9+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
10+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
11+
12+
</head>
13+
<body class="container pt-5 pb-5">
14+
<main>
15+
<!-- <h1>Module 5</h1>
16+
<p class="fs-5 col-md-8">Here I implement a simulation genetic drift with natural selection.</p>
17+
<div class="col-md-6">
18+
<h2>Tech used projects</h2>
19+
<p>Here are some libraries used in this module</p>
20+
<ul class="icon-list">
21+
<li><a href="https://getbootstrap.com/">Bootstrap</a></li>
22+
<li><a href="https://www.chartjs.org/">Chart Js</a></li>
23+
</ul>
24+
</div>
25+
<div class="mb-5">
26+
<a href="https://github.com/techboy-coder/nature-in-code" class="btn btn-primary btn-lg px-4">Other examples made by me</a>
27+
</div> -->
28+
29+
<hr>
30+
31+
</main>
32+
<!-- <form action="" id="input">
33+
<label for="samples">Number of samples</label>
34+
<input type="number" name="samples" id="samples" placeholder="100" value="100">
35+
<label for="generations">Number of generations</label>
36+
<input type="number" name="generations" id="generations" placeholder="100" value="100">
37+
<label for="a1">Frequency of a1 (between 1 and 0; a2 = 1-a1) </label>
38+
<input type="number" name="a1" id="a1" placeholder="0.5" value="0.3" step="0.0001">
39+
</form> -->
40+
<!-- <button type="button" onclick="app();">Run Simulation</button> -->
41+
<canvas id="myChart"></canvas>
42+
<script src="app.js"></script>
43+
</body>
44+
</html>

Module 5/notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Individual can only mate with partner in distance d on a N x M Grid
2+
- Calculate Probs of Alleles variations
3+
- Repeat for g generations

0 commit comments

Comments
 (0)