Governance charts for recurrence scenarios and age curves
This commit is contained in:
@@ -138,7 +138,113 @@ export function interpretabilityFigures(
|
||||
},
|
||||
];
|
||||
}
|
||||
case 'scenarios':
|
||||
return (report['recurrencia']['escenarios'] as any[]).slice(0, 6).map((e) => ({
|
||||
title: `${e.cohorte_nombre} · ${e.escenario} (n = ${e.n}, ${e.recaidas} recaídas)`,
|
||||
figure: {
|
||||
data: [
|
||||
...banded(
|
||||
'Kaplan-Meier (IC 95 %)',
|
||||
{ x: e.km.months, y: e.km.S, low: e.km.low, high: e.km.high },
|
||||
PALETTE[0],
|
||||
),
|
||||
{
|
||||
x: e.weibull.t,
|
||||
y: e.weibull.S,
|
||||
name: 'Weibull',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
line: { color: PALETTE[1], dash: 'dot' },
|
||||
},
|
||||
{
|
||||
x: e.weibull_fractional.t,
|
||||
y: e.weibull_fractional.S,
|
||||
name: 'Weibull fraccional',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
line: { color: PALETTE[2] },
|
||||
},
|
||||
points(
|
||||
'Modelo (IC 95 % bootstrap)',
|
||||
report['recurrencia']['horizons_months'],
|
||||
e.points.COMB,
|
||||
),
|
||||
],
|
||||
layout: {
|
||||
xaxis: { title: { text: 'Meses desde el diagnóstico' } },
|
||||
yaxis: { title: { text: 'Supervivencia libre de recaída' } },
|
||||
},
|
||||
},
|
||||
}));
|
||||
case 'age_curves': {
|
||||
// The metric's own curve; a topography has only electrodes: its first one.
|
||||
const value = report['curves']['value'] ?? Object.values(report['curves'])[0];
|
||||
if (!value) return [];
|
||||
const label = report['curves']['value'] ? '' : ` · ${Object.keys(report['curves'])[0]}`;
|
||||
if (value.kind === 'count_rate') {
|
||||
return [
|
||||
{
|
||||
title: `Tasa de referencia: ${value.rate.toFixed(3)} por minuto (${value.reference} estudios)`,
|
||||
figure: {
|
||||
data: [
|
||||
{
|
||||
x: value.ages,
|
||||
y: [value.rate, value.rate],
|
||||
name: 'Tasa',
|
||||
type: 'scatter',
|
||||
mode: 'lines',
|
||||
},
|
||||
],
|
||||
layout: {
|
||||
xaxis: { title: { text: 'Edad (meses)' } },
|
||||
yaxis: { title: { text: 'Eventos por minuto' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
const c = value.curve;
|
||||
return [
|
||||
{
|
||||
title: `Curva de referencia por edad (p5, mediana, p95)${label}`,
|
||||
figure: {
|
||||
data: [
|
||||
...banded(
|
||||
'p5–p95',
|
||||
{ x: c.age_months, y: c.median, low: c.p5, high: c.p95 },
|
||||
PALETTE[4],
|
||||
),
|
||||
].map((d, i) => (i === 1 ? { ...d, name: 'Mediana' } : d)),
|
||||
layout: {
|
||||
xaxis: { title: { text: 'Edad (meses)' }, type: 'log' },
|
||||
yaxis: { title: { text: 'Valor' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function points(
|
||||
name: string,
|
||||
x: number[],
|
||||
p: { S: number[]; low: number[]; high: number[] },
|
||||
): Partial<Plotly.Data> {
|
||||
return {
|
||||
x,
|
||||
y: p.S,
|
||||
error_y: {
|
||||
type: 'data',
|
||||
symmetric: false,
|
||||
array: p.high.map((h, i) => h - p.S[i]),
|
||||
arrayminus: p.S.map((v, i) => v - p.low[i]),
|
||||
},
|
||||
name,
|
||||
type: 'scatter',
|
||||
mode: 'markers',
|
||||
marker: { color: PALETTE[4], size: 9 },
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user