Skip to content

Commit e9e9b9d

Browse files
committed
interactive plot for deamination parameters choice
1 parent 3dada80 commit e9e9b9d

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ With the default parameters, the substitution frequency is depicted in fig 2:
9696

9797
<img src="./img/geometric_model.png" width="300">
9898

99+
One can try different parameters for deamination using this interactive plot: [maxibor.github.io/adrsm](https://maxibor.github.io/adrsm)
100+
99101
**Figure 2:** Substitution frequency.
100102

101103
For each nucleotide, a random number `Pu` is sampled from an <a href="https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)">uniform distribution</a> (of support [0 ,1]) and compared to the corresponding value `Pg` of the rescaled geometric PMF at this nucleotide.

index.html

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>ADRSM geometric</title>
6+
<script src="https://unpkg.com/[email protected]/dist/math.min.js"></script>
7+
8+
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
9+
10+
<style>
11+
input[type=text] {
12+
width: 300px;
13+
}
14+
input {
15+
padding: 6px;
16+
}
17+
body, html, input {
18+
font-family: sans-serif;
19+
font-size: 11pt;
20+
21+
}
22+
form {
23+
margin: 20px 0;
24+
}
25+
</style>
26+
</head>
27+
28+
<body>
29+
<p>
30+
<h1>Plotting aDNA simulated damage with geometric distribution for ADRSM</h1>
31+
</p>
32+
<form id="form">
33+
<label for="eq">Parameter for geometric distribution:</label>
34+
<input type="number" id="param" step="0.01" min="0.1" max="1" value="0.5" />
35+
<label for="eq">Sequence size:</label>
36+
<input type="number" id="seqsize" min="20" max="100" value="30" />
37+
<label for="eq">Max probability:</label>
38+
<input type="number" id="maxproba" step="0.01" min="0.01" max="1" value="0.3" />
39+
<input type="submit" value="Draw" />
40+
</form>
41+
42+
<div id="plot"></div>
43+
44+
<script>
45+
function draw() {
46+
try {
47+
// compile the expression once
48+
const param = document.getElementById('param').value
49+
const seqsize = document.getElementById('seqsize').value
50+
const maxproba = document.getElementById('maxproba').value
51+
52+
// evaluate the expression repeatedly for different values of x
53+
const xValues = math.range(1, seqsize, 1).toArray()
54+
const yValues = xValues.map(function (x) {
55+
res = ((1 - param) ** (x - 1)) * param
56+
return (res)
57+
})
58+
59+
themin = math.min(yValues)
60+
themax = math.max(yValues)
61+
minproba = 0
62+
const nValues = yValues.map(function (x) {
63+
res = (x - themin) / (themax - themin) * (maxproba - minproba) + minproba
64+
return (res)
65+
})
66+
67+
68+
// render the plot using plotly
69+
const trace1 = {
70+
x: xValues,
71+
y: nValues,
72+
type: 'scatter'
73+
}
74+
75+
var layout = {
76+
title: 'aDNA simulated damage with geometric distribution for ADRSM',
77+
xaxis: {
78+
title: 'nucleotide position'
79+
},
80+
yaxis: {
81+
title: 'probability'
82+
}
83+
};
84+
const data = [trace1]
85+
Plotly.newPlot('plot', data, layout)
86+
}
87+
catch (err) {
88+
console.error(err)
89+
alert(err)
90+
}
91+
}
92+
93+
document.getElementById('form').onsubmit = function (event) {
94+
event.preventDefault()
95+
draw()
96+
}
97+
98+
draw()
99+
</script>
100+
101+
</body>
102+
103+
</html>

0 commit comments

Comments
 (0)