Published
Edited
Feb 27, 2021
Insert cell
Insert cell
allfeatures_in = (await d3.tsv("https://raw.githubusercontent.com/bmesuere/files/main/Y1a_allfeatures.pin", d3.autoType)).map(d => {d.decoy = d.Proteins.startsWith("decoy"); return d;})
Insert cell
allfeatures_out = (await d3.tsv("https://raw.githubusercontent.com/bmesuere/files/main/Y1a_allfeatures.pout")).map(d => {d.decoy = d.proteinIds.startsWith("decoy"); return d;})
Insert cell
searchenginefeatures_in = (await d3.tsv("https://raw.githubusercontent.com/bmesuere/files/main/Y1a_searchenginefeatures.pin", d3.autoType)).map(d => {d.decoy = d.Proteins.startsWith("decoy"); return d;})
Insert cell
searchenginefeatures_out = (await d3.tsv("https://raw.githubusercontent.com/bmesuere/files/main/Y1a_searchenginefeatures.pout")).map(d => {d.decoy = d.proteinIds.startsWith("decoy"); return d;})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
qvalue = {
const result = [];
let prev_all = 0;
let prev_i = 0;
let prev_search = 0;
qs.forEach(i => {
const all = allfeatures_out.filter(d => d["q-value"] <= i).length;
const search = searchenginefeatures_out.filter(d => d["q-value"] <= i).length;
if (all) {
if (prev_all === 0) result.push({q_value: prev_i, count: 0 , type: "all"});
result.push({q_value: i, count: all , type: "all"});
}
if (search) {
if (prev_search === 0) result.push({q_value: prev_i, count: 0 , type: "search_engine"});
result.push({q_value: i, count: search, type: "search_engine"});
}
prev_all = all;
prev_search = search;
prev_i = i;
});
return result;
}
Insert cell
{
const lines = vl.markLine().encode(
vl
.x()
.fieldQ("q_value")
.scale({ type: "log" }),
vl.y().fieldQ("count"),
vl.color().fieldN("type")
);
return JSON.stringify(
vl
.layer(lines)
.data(qvalue)
.toObject()
);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scorePlot = function(field, step, data) {
return vl
.markBar()
.encode(
vl.x({ field: field, bin: { step: step }, type: "quantitative" }),
vl.color().fieldN("decoy"),
vl.y().count()
)
.data(data)
.render();
}
Insert cell
Insert cell
Insert cell
Insert cell
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