Published
Edited
Apr 4, 2022
1 fork
14 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
result = `${testname}_result`
Insert cell
roc = d3.sort(d3.shuffle(data.filter((d) => d[result] >= 0)), (d) => d[result])
Insert cell
threshold = (roc[threshold_i][result] + roc[threshold_i + 1][result]) / 2
Insert cell
// this is the threshold value where the test's interpretation changes (from "NOT detected" to "DETECTED")
threshold_i = {
const interpretation = `${testname}_interpretation`;
for (let i = 0; i < roc.length - 1; i++)
if (roc[i][interpretation] !== roc[i + 1][interpretation]) return i;

// for random and ideal, set the threshold at the number of true negative
return N - 1;
}
Insert cell
T = Uint8Array.from(roc, (d) => +(d.status === "P"))
Insert cell
X = d3.cumsum(T)
Insert cell
P = X[T.length - 1] // equiv. d3.sum(T)
Insert cell
Y = X.map((x, i) => 1 + i - x) // equiv. d3.cumsum(T, t => 1 - t)
Insert cell
N = Y[T.length - 1] // equiv. d3.sum(T, t => 1 - t)
Insert cell
AUC = 1 - d3.sum(T, (t, i) => (1 - t) * X[i]) / (N * P)
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("supplementary_dataset2.xlsx")
.xlsx()
.then((xl) => xl.sheet("all_samples", { headers: true }))
.then(
(data) => (
data.forEach((d) => {
d.status = d.samplecollection === "obb_negatives" ? "N" : "P";

d.status_result = 1 + +(d.status === "P");

d.diasorin_result =
d.diasorin_result[0] === "<"
? +d.diasorin_result.slice(1).trim()
: d.diasorin_result;

d.siemens_result =
d.siemens_result[0] === "<"
? +d.siemens_result.slice(1).trim()
: d.siemens_result;

d.random_result = random();
}),
data
)
)
Insert cell
random = d3.randomExponential(1)
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