Survival scenario charts on the governance page; breast treatment entity

This commit is contained in:
Roberto Treviño
2026-11-26 19:03:39 -06:00
parent d1f9dcbea8
commit 0e4d838d44
10 changed files with 98 additions and 43 deletions
+62 -37
View File
@@ -70,6 +70,15 @@ export function interpretabilityFigures(
},
},
},
// Its clinical scenarios, those with enough deaths to draw.
...((report['escenarios'] ?? []) as any[]).map((e) =>
scenarioFigure(
`${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, fallecidos = ${e.fallecidos.toLocaleString('es-MX')})`,
e,
e.horizons_months,
'Supervivencia S(t)',
),
),
];
}
case 'subgroups':
@@ -139,43 +148,16 @@ 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' } },
},
},
}));
return (report['recurrencia']['escenarios'] as any[])
.slice(0, 6)
.map((e) =>
scenarioFigure(
`${e.cohorte_nombre} · ${e.escenario} (n = ${e.n}, ${e.recaidas} recaídas)`,
e,
report['recurrencia']['horizons_months'],
'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];
@@ -228,6 +210,49 @@ export function interpretabilityFigures(
}
}
/** One clinical scenario: Kaplan-Meier with its band, the classic and fractional Weibull,
* and the model's points with their bootstrap band. */
function scenarioFigure(
title: string,
e: any,
horizons: number[],
yTitle: string,
): { title: string; figure: Figure } {
return {
title,
figure: {
data: [
...banded(
'Kaplan-Meier (IC 95 % Greenwood)',
{ 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] },
},
{
x: e.weibull_fractional.t,
y: e.weibull_fractional.S,
name: 'Weibull fraccional',
type: 'scatter',
mode: 'lines',
line: { color: PALETTE[2], dash: 'dash' },
},
points('LR + HBN combinado (IC 95 % bootstrap)', horizons, e.points.COMB),
],
layout: {
xaxis: { title: { text: 'Meses desde el diagnóstico' } },
yaxis: { title: { text: yTitle } },
},
},
};
}
function points(
name: string,
x: number[],