JMP의 KM 플롯 위험표는 무엇입니까?https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/mp/55338/highlight/true#M31302 에 따르면 위험을 생성하는 방법을 제공해 주시겠습니까? KM 플롯 아래에 테이블이 있습니까? 댓글에서 스크립트를 따라해보려고 했는데 해결이 안되서 닫혀버렸네요.
dt = Current Data Table ();
minT = 0;
maxT = 25;
stepT = 1;
Summarize( lv = by( :group) );
obj = Survival(
Y( :time ),
Censor( :"reject"n ),
Grouping( :group ),
Failure Plot( 0 ),
SendToReport(
Dispatch(
{"Survival Plot"},
"1",
ScaleBox,
{Min( 0 ), Max( 25 ), Inc( 1 ), Minor Ticks( 1 )}
),
Dispatch(
{"Survival Plot"},
"time",
TextEditBox,
{Set Text( "Times(years)" )}
)
)
) << report;
obj[List Box( 2 )] << append( Table Box( String Col Box( "No at Risk | Year", lv ) ) );
Tab1 = (obj[lv[1]][Table Box( 1 )] << get);
Tab2 = (obj[lv[2]][Table Box( 1 )] << get);
For( T = minT, T <= maxT, T += stepT,
lp = Max( Loc( Matrix( Tab1 [years] ) <= T ) );
AR1 = Tab1["At Risk"][lp];
lp = Max( Loc( Matrix( Tab2 [years]) <= T ) );
AR2 = Tab2["At Risk"][lp];
obj[List Box( 2 )][Table Box( 1 )] << append( Number Col Box( Char( T ), {AR1, AR2} ) );
);출력은 첨부 사진으로 보여주었습니다. 스크립트를 수정해 주시겠어요?
감사합니다
데이터 탐색 및 시각화Re: JMP의 KM 플롯 위험표는 무엇입니까?코드를 좀 더 매개변수화하려고 했습니다. minT, maxT, stepT, ycol, 그룹화를 변경하고 테이블을 사용하는 경우 원하는 작업을 수행합니까?
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Rats.jmp");
minT = 100;
maxT = 350;
stepT = 50;
ycol = "days";
grouping = "Group";
Summarize(dt, groups = by(Eval(grouping)));
obj = dt << Survival(
Y(Eval(ycol)),
Censor(:Censor),
Grouping(Eval(grouping)),
Show Points(1),
SendToReport(
Dispatch({"Survival Plot"}, "1", ScaleBox,
{Min(minT), Max(maxT), Inc(stepT), Minor Ticks(1)}
),
)
);
rep = Report(obj);
rep[List Box(2)] << append(tb = Table Box(String Col Box("No at Risk ("||ycol||")", groups)));
rep[List Box(2)] << Append(Spacer Box(Size(0,20)));
tabs = {};
For Each({group}, groups,
Insert Into(tabs, Eval List({rep[OutlineBox(group), Table Box(1)] << get}));
);
For(T = minT, T <= maxT, T += stepT,
ARs = {};
For Each({tab}, tabs,
lp = Max(Loc(Matrix(tab[ycol]) <= T));
Insert Into(ARS, tab["At Risk"][lp])
);
tb << append(Number Col Box(Char(T), ARs));
);
편집: 작은 수정
Re: JMP의 KM 플롯 위험표는 무엇입니까?안녕하세요 Jarmo, 도움을 주셔서 감사합니다. 효과가 있었어요!
최고, 테라차이
Re: JMP의 KM 플롯 위험표는 무엇입니까?생존자 보고서에 기본적으로 사용할 수 있는 스크립트도 있습니다. 대부분의 경우에 작동할 수 있지만 저는 이 JMP 플랫폼이나 분석에 익숙하지 않기 때문에 작동할지는 확실하지 않습니다. 또한 계산을 수정하여 정확하지 않을 수도 있습니다.
먼저 생존자 보고서를 열어야 합니다.

그런 다음 스크립트를 실행하면 몇 가지 사항을 묻는 메시지가 표시됩니다.

내용을 입력하고 확인을 누르세요.

그런 다음 기존 보고서에 표를 추가합니다.

아래 스크립트(또한 첨부됨). 사용에 따른 책임은 본인에게 있습니다. 계산은 확인되지 않았습니다.
더보기...
/*""" Add risk table to Survival platform
Author: jthi
Creation Date: 2024-07-31
Creation JMP Version: JMP Pro 18.0.1
Description: Based on
https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/m-p/305898/highlight/true#M56162
Todo:
* Show steps to user before pressing OK
* Remove modal window
* Turn into add-in / proper script
* Add instructions / title to UI
* Add utility modal
"""*/
Names Default To Here(1);
ask_steps = function({}, {Default Local},
nw = New Window("Fill in Time to Event Steps", << Type("Modal Dialog"), << Return Result,
H List Box(
Panel Box("Fill in steps",
Lineup Box(N Col(2),
Text Box("Min Time"),
neb_min = Number Edit Box(.),
Text Box("Max Time"),
neb_max = Number Edit Box(.),
Text Box("Step Time"),
neb_step = Number Edit Box(.),
Text Box("Interpolate last"),
cb_interpolate = Check Box({""}, << Set All(1))
)
),
Spacer Box(Size(20, 0)),
Panel Box("Actions",
Button Box("OK"),
Button Box("Cancel")
)
)
, << Set Window Icon("Survival")
);
If(nw["Button"] != 1,
Throw("Cancelled");
);
min_t = nw["neb_min"];
max_t = nw["neb_max"];
step_t = nw["neb_step"];
If(Any(Is Missing(min_t), Is Missing(max_t), Is Missing(step_t)),
Throw("Steps not filled in");
);
interpolate_last = N Items(nw["cb_interpolate"]);
return(Eval List({min_t, max_t, step_t, interpolate_last}));
);
add_risk_table = function({platform_ref, min_t, max_t, step_t, interpolate_last}, {Default Local},
rep = Report(platform_ref);
dt = platform_ref << Get Data Table;
ycol = ((rep << XPath("//TextBox[text()='Time to event: ']"))[1] << sib) << get text;
grouping_col = ((rep << XPath("//TextBox[text()='Grouped by ']"))[1] << sib) << get text;
Summarize(dt, groups = by(Eval(grouping_col)));
steps = min_t::max_t::step_t;
vals = steps;
For Each({group}, groups,
m_tb = rep[OutlineBox(group), Table Box(1)] << get as matrix;
times = m_tb[0, 1];
atrisk = m_tb[0, N Cols(m_tb)];
cur_steps = Step(steps, times, atrisk); // Last one isn't assumed in this
If(interpolate_last,
If(times[N Rows(times), 1] < max_t & Is Missing(cur_steps[N Cols(cur_steps)]),
cur_steps[N Cols(cur_steps)] = atrisk[N Rows(times), 1];
);
);
vals = vals |/ cur_steps;
);
pb = Panel Box("Risk Table", tb_results = Table Box(
String Col Box(Eval Insert("No at Risk (^ycol^)"), groups),
));
For(i = 1, i <= N Cols(vals), i++,
cur_vals = vals[0, i];
title = Char(Remove From(cur_vals, 1)[1]);
tb_results << Append(Number Col Box(title, cur_vals));
);
rep[List Box(2)] << Append(pb);
rep[List Box(2)] << Append(Spacer Box(Size(0, 10)));
);
cur_rep = Current Report();
If(Is Empty(cur_rep),
Throw("No reports open");
);
ob_ref = cur_rep << XPath("//OutlineBox[@helpKey='Surv']");
If(N Items(ob_ref) == 0,
Throw("No Surv platform found");
);
Try(
{min_t, max_t, step_t, interpolate_last} = ask_steps();
platform_ref = ob_ref[1] << get scriptable object;
add_risk_table(platform_ref, min_t, max_t, step_t, interpolate_last);
,
Throw("Other issues: " || char(exception_msg));
);
Write();
Re: JMP의 KM 플롯의 위험 표?이 스크립트에 감사합니다! 정말 마음에 들어요. 아래 설정("그룹화" 및 "기준" 지정)을 사용하여 여러 생존 곡선을 한 번에 생성할 때 위험 표는 첫 번째 플롯에만 추가됩니다. 모든 플롯에 추가할 수 있는 방법이 있나요?

Re: JMP의 KM 플롯의 위험 표?가능해야 하지만 스크립트를 수정해야 합니다. 이 버전이 당신에게 효과가 있다면 시도해 볼 수 있습니다:
더 보기...
Names Default To Here(1);
ask_steps = function({}, {Default Local},
nw = New Window("Fill in Time to Event Steps", << Type("Modal Dialog"), << Return Result,
H List Box(
Panel Box("Fill in steps",
Lineup Box(N Col(2),
Text Box("Min Time"),
neb_min = Number Edit Box(.),
Text Box("Max Time"),
neb_max = Number Edit Box(.),
Text Box("Step Time"),
neb_step = Number Edit Box(.),
Text Box("Interpolate last"),
cb_interpolate = Check Box({""}, << Set All(1))
)
),
Spacer Box(Size(20, 0)),
Panel Box("Actions",
Button Box("OK"),
Button Box("Cancel")
)
)
, << Set Window Icon("Survival")
);
If(nw["Button"] != 1,
Throw("Cancelled");
);
min_t = nw["neb_min"];
max_t = nw["neb_max"];
step_t = nw["neb_step"];
If(Any(Is Missing(min_t), Is Missing(max_t), Is Missing(step_t)),
Throw("Steps not filled in");
);
interpolate_last = N Items(nw["cb_interpolate"]);
return(Eval List({min_t, max_t, step_t, interpolate_last}));
);
add_risk_table = function({platform_ref, min_t, max_t, step_t, interpolate_last}, {Default Local},
rep = Report(platform_ref);
dt = platform_ref << Get Data Table;
ycol = ((rep << XPath("//TextBox[text()='Time to event: ']"))[1] << sib) << get text;
grouping_col = ((rep << XPath("//TextBox[text()='Grouped by ']"))[1] << sib) << get text;
Summarize(dt, groups = by(Eval(grouping_col)));
steps = min_t::max_t::step_t;
vals = steps;
For Each({group}, groups,
m_tb = rep[OutlineBox(group), Table Box(1)] << get as matrix;
times = m_tb[0, 1];
atrisk = m_tb[0, N Cols(m_tb)];
cur_steps = Step(steps, times, atrisk); // Last one isn't assumed in this
If(interpolate_last,
If(times[N Rows(times), 1] < max_t & Is Missing(cur_steps[N Cols(cur_steps)]),
cur_steps[N Cols(cur_steps)] = atrisk[N Rows(times), 1];
);
);
vals = vals |/ cur_steps;
);
pb = Panel Box("Risk Table", tb_results = Table Box(
String Col Box(Eval Insert("No at Risk (^ycol^)"), groups),
));
For(i = 1, i <= N Cols(vals), i++,
cur_vals = vals[0, i];
title = Char(Remove From(cur_vals, 1)[1]);
tb_results << Append(Number Col Box(title, cur_vals));
);
rep[List Box(2)] << Append(pb);
rep[List Box(2)] << Append(Spacer Box(Size(0, 10)));
);
cur_rep = Current Report();
If(Is Empty(cur_rep),
Throw("No reports open");
);
ob_refs = cur_rep << XPath("//OutlineBox[@helpKey='Surv']");
If(N Items(ob_refs) == 0,
Throw("No Surv platform found");
);
Try(
{min_t, max_t, step_t, interpolate_last} = ask_steps();
For Each({ob_ref}, ob_refs,
platform_ref = ob_ref << get scriptable object;
add_risk_table(platform_ref, min_t, max_t, step_t, interpolate_last);
);
,
Throw("Other issues: " || char(exception_msg));
);
Write();
스크립트 끝부분은 몇 가지만 변경했고, 기본적으로 루프마다 하나씩 추가했고(변수 이름 하나를 변경했습니다).
Re: JMP의 KM 플롯의 위험 표?빠른 답변 감사합니다! 그런데 이 메시지가 나오네요?

Re: JMP의 KM 플롯의 위험 표?100번째 줄에 s 하나가 빠졌습니다.

나는 문제를 해결하기 위해 이전 게시물을 편집했습니다.
Re: JMP의 KM 플롯의 위험 표?다시 한번 감사합니다! 이제 작동합니다!
출력을 QC하기 위해 참조 그림을 다시 만들었고(아래 JMP 대 참조 참조 참조) 몇 가지 세부 사항을 알아챘습니다. 왼쪽에서 시작하여 시간 = 0에서 위험에 처한 숫자인 40은 정확하지만 이후의 시간점은 1로 부풀려집니다. 예외는 실제 숫자가 0인 경우인데, 스크립트에서 정확하게 나열합니다. 마지막으로 마지막 시간점에 1이 있는데, 거기에 없어야 합니다. Excel에서 이것을 수정할 수 있지만 스크립팅 수정이 있다면 대단할 것입니다!

Re: JMP의 KM 플롯의 위험 표?어느 계산이 잘못된지 잘 모르겠습니다. 내 스크립트에 있다면 아마도 여기 어딘가에서 수정할 수 있을 것입니다.

결과가 어떻게 나와야 하는지 알려면 정답이 포함된 예제 데이터 세트가 필요합니다(하지만 제 스크립트의 보간 옵션은 제대로 작동하지 않는 것 같습니다).
Re: JMP의 KM 플롯의 위험 표?"부풀려진" 위험군 수치에 대한 후속 조치입니다. VP 폐암 데이터세트에 대한 스크립트(감사합니다!)를 사용하여 표준군의 경우 400명, 테스트군의 경우 200명, 400명, 600명, 800명씩 위험군 수치를 1명 더 얻었습니다.

데이터 표를 보면 정확한 시간 지점(표준의 경우 200 - 첫 번째 분홍색 행)이 있는 값은 위험 수치가 올바르게 표시됩니다. 그러나 400, 600, 800과 같이 정확한 일치가 없는 경우 현재 스크립트는 지정된 시간 지점 전의 수치를 가져옵니다. 스크립팅으로 이런 경우를 수정할 수 있다면 좋을 텐데요.


Re: JMP의 KM 플롯의 위험 표?이전 값이 아닌 경우 무엇을 표시해야 합니까?