Published
Edited
May 5, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function generateRandomSeq(stringLength, weightedVal) {
let sequence = "";
let base1 = ["C", "G"];
let base2 = ["A", "T"];
for (let index = 0; index < stringLength; index++){
var randint = Math.floor(Math.random() * 100);// 0 to 99
if (randint < weightedVal){
sequence = sequence + base1[Math.floor(Math.random() * base1.length)];
}
else{
sequence = sequence + base2[Math.floor(Math.random() * base2.length)];
}
}
return sequence
}
Insert cell
Plot.plot({
marks: [
Plot.rectY(data, Plot.binX({y: "sum"}, {x: "column"}))
]
})
Insert cell
Insert cell
calcGC(generateRandomSeq(10, 40))
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.rectY(randomSeq, Plot.binX({y: randomSeq}, {x: "Sequence"}))
]
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more