説明・学習用の架空例
治療経過を、スイマープロットで見渡す
空欄は記録なし。追跡終了は死亡を意味しません。この3例から治療効果を比較しません。
| ID | 治療終了 | 反応 | 再発 | 追跡終了 |
|---|---|---|---|---|
| A | 6 | 2 | 9 | 12 |
| B | 8 | 3 | 記録なし | 10 |
| C | 4 | 記録なし | 記録なし | 7 |
Python再現用コード(未実行)
import matplotlib.pyplot as plt
rows = [('A',6,2,9,12), ('B',8,3,None,10), ('C',4,None,None,7)]
fig, ax = plt.subplots()
for y, (name, end, response, relapse, follow) in enumerate(rows):
assert 0 <= end <= follow
ax.hlines(y, 0, follow, color='gray', linewidth=2)
ax.hlines(y, 0, end, color='teal', linewidth=10)
for event, marker in [(response, 'o'), (relapse, 'D')]:
if event is not None:
assert 0 <= event <= follow
ax.plot(event, y, marker=marker, color='black', markerfacecolor='white')
ax.plot(follow, y, marker='|', color='black', markersize=18)
ax.set_yticks(range(len(rows)), [r[0] for r in rows])
ax.set_xlabel('Months from treatment start')
ax.set_xlim(-0.5, 13)
from matplotlib.lines import Line2D
ax.legend(handles=[Line2D([0],[0],color='teal',lw=8,label='Treatment'),Line2D([0],[0],color='gray',lw=2,label='Follow-up'),Line2D([0],[0],marker='o',linestyle='',color='black',label='Response'),Line2D([0],[0],marker='D',linestyle='',color='black',label='Relapse'),Line2D([0],[0],marker='|',linestyle='',color='black',label='Follow-up end')])
fig.tight_layout()
fig.savefig('swimmer.png', dpi=200)
照合するところ
- Aの治療終了6、反応2、再発9、追跡終了12を図で照合。
- B・Cの記録なしが0月のイベントになっていないことを確認。
- 観察期間と治療期間を同じ棒で表していないことを確認。