Public
Edited
Jun 18, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(adsl)
Insert cell
Plot.plot({
y: {
grid: true,
label: 'Age (years)',
labelArrow: 'none',
labelAnchor: 'center'
},
color: {
domain: ['Xanomeline High Dose', 'Xanomeline Low Dose', 'Placebo'],
range: ['#4a8a8f', '#86cac6', '#004f5b'],
legend: true
},
title: 'Age',
marks: [
Plot.boxY(adsl, {x: "TRT01A", y: "AGE", fill: "TRT01A"}),
Plot.tip(adsl, Plot.pointerX({x: "TRT01A"})),
Plot.axisX({label: null, marginBottom: 40, dy: 10})
]
})
Insert cell
Plot.plot({
y: {
label: "Count (n)",
labelAnchor: "center",
labelArrow: false
},
color: {
domain: ['Xanomeline High Dose', 'Xanomeline Low Dose', 'Placebo'],
range: ['#4a8a8f', '#86cac6', '#004f5b'],
legend: true
},
marks: [
Plot.barY(
adsl,
Plot.groupX({y: "count"}, {x: "TRT01A", fx: "ETHNIC", fill: "TRT01A"}),
),
Plot.axisX({label: null, tickRotate: 315, marginBottom: 100, dy: 75, dx: -50})
]
})
Insert cell
Insert cell
adaeRaw = FileAttachment("adae@1.json").json()
Insert cell
adae = adaeRaw.filter(row => row.TRT01A != "").sort((a, b) => b.TRT01AN - a.TRT01AN)
Insert cell
Inputs.table(adae)
Insert cell
Plot.plot({
x: {
label: null
},
y: {
label: null
},
width: 1000,
marginLeft: 400,
color: {
domain: ['Xanomeline High Dose', 'Xanomeline Low Dose', 'Placebo'],
range: ['#4a8a8f', '#86cac6', '#004f5b'],
legend: true
},
marks: [
Plot.barX(adae, Plot.groupY({x: "count"}, {y: "AEBODSYS", fill: "TRTA", sort: {y: "-x"}, tip: true}))
]
})
Insert cell
viewof patient = Inputs.select(
adae.map(d => d.USUBJID).filter((value, index, array) => array.indexOf(value) === index),
{label: "Patient"}
)
Insert cell
adaePatient = adae.filter(d => d.USUBJID == patient)
Insert cell
Inputs.table(adaePatient)
Insert cell
maxPatientEndDay = d3.max(adaePatient.map(d => typeof d.AENDY === 'undefined' ? 100 : d.AENDY))
Insert cell
Plot.plot({
marginLeft: 250,
height: 400,
width: 800,
x: {
label: "Days",
labelArrow: 'none',
labelAnchor: "center"
},
color: {
domain: ["MILD", "MODERATE", "SEVERE"],
range: ['#fdd26e', '#ff8041', '#cc66ff'],
legend: true
},
marks: [
Plot.ruleY(adaePatient, {x1: "ASTDY", x2: d => typeof d.AENDY === "undefined" ? maxPatientEndDay: d.AENDY, y: "AEDECOD", stroke: "AESEV", markerStart: 'dot', markerEnd: 'dot', tip: true}),
Plot.text(adaePatient, {x: "ASTDY", y: "AEDECOD", text: d => typeof d.AENDY === "undefined" ? "Ongoing": null, lineAnchor: "bottom", fontSize: 12, dy: -10, dx: 30}),
Plot.ruleX([0], {strokeDasharray: [5, 5], strokeOpacity: 0.4})
]
})
Insert cell
Insert cell
adlbcRaw = FileAttachment("adlbc.json").json()
Insert cell
adlbc = adlbcRaw.filter(d => d.LBNRIND !== "")
Insert cell
Inputs.table(adlbc)
Insert cell
Plot.plot({
y: {
percent: true
},
color: {
domain: ["LOW", "NORMAL", "HIGH"],
range: ["#fdd26e","#86cac5", "#ff8041"],
legend: true
},
marks: [
Plot.barY(
adlbc,
Plot.groupX(
{ y: "count" },
{
fill: "LBNRIND",
x: "PARAM",
sort: { y: "x"},
offset: "normalize",
tip: {
format: {
fill: d => `Range: ${d}`,
y: d => `${d3.format(".1%")(d / 100)}`
}
}
}
)
),
// Plot.tip(adlbc, Plot.pointer({x: "PARAM", title: d => `Range: ${d.LBNRIND}`})),
Plot.axisX({
label: null,
tickRotate: 315,
tickSize: 0,
tickFormat: d => d.match(/.+?(?=\s\()/)[0],
marginBottom: 150,
marginLeft: 100,
textAnchor: 'end'
})
]
})
Insert cell
viewof selectedLabs = Inputs.checkbox(
adlbc.map(d => d.PARAM).filter((value, index, array) => array.indexOf(value) === index),
{label: "Labs to Display"}
)
Insert cell
adlbcSubset = adlbc.filter(d => selectedLabs.includes(d.PARAM)).filter(d => d.USUBJID == patient)
Insert cell
// faceting doesn't work b/c all plots are put on the same scale
htl.html`${selectedLabs.map((labParam) => {
return Plot.plot({
color: {
domain: ["LOW", "NORMAL", "HIGH"],
range: ["#fdd26e","#86cac5", "#ff8041"],
legend: true
},
marks: [
Plot.frame(),
Plot.axisY({label: labParam, labelArrow: false, labelAnchor: 'center'}),
Plot.axisX({labelArrow: false, labelAnchor: 'center'}),
Plot.line(adlbcSubset.filter(d => d.PARAM === labParam), {
x: "ADY",
y: "AVAL",
stroke: "#004f5b"
}),
Plot.dot(adlbcSubset.filter(d => d.PARAM === labParam), {
x: "ADY",
y: "AVAL",
fill: "LBNRIND"
}),
Plot.ruleY(adlbcSubset, {
x1: d => d3.min(adlbcSubset.filter(d => d.PARAM === labParam).map(d => d.ADY)),
x2: d => d3.max(adlbcSubset.filter(d => d.PARAM === labParam).map(d => d.ADY)),
// y: d3.min(adlbcSubset.filter(d => d.PARAM === labParam).map(d => d.A1LO)), // can be multiple for each visit
y: "A1LO",
strokeDasharray: [5, 5],
strokeOpacity: 0.4
}),
Plot.ruleY(adlbcSubset, {
x1: d => d3.min(adlbcSubset.filter(d => d.PARAM === labParam).map(d => d.ADY)),
x2: d => d3.max(adlbcSubset.filter(d => d.PARAM === labParam).map(d => d.ADY)),
y: d3.max(adlbcSubset.filter(d => d.PARAM === labParam).map(d => d.A1HI)), // can be multiple for each visit
strokeDasharray: [5, 5],
strokeOpacity: 0.4
})
]
})
})}`
Insert cell
Inputs.table(adlbcSubset.filter(d => d.PARAM === "Potassium (mmol/L)"))
Insert cell
adlbcSubset.filter(d => d.PARAM === "Potassium (mmol/L)").map(d => d.A1HI)
Insert cell
adaePatient.map(d => {
return {
ASTDY: d.ASTDY,
AENDY: d.AENDY,
AEDECOD: d.AEDECOD,
AESEV: d.AESEV
}
})
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