繁体   English   中英

Kaplan-Meier包括生存和移植数据

[英]Kaplan-Meier including survival and transplant data

我所拥有的是使用R进行机械性心脏支持的患者的Kaplan-Meier分析。

我需要的是将以下数据添加到图中(如示例中所示):

  • 因心脏移植而幸存的患者(HTX)
  • 死亡的病人

换句话说,有两组,其中一组是另一组(所有患者)的子集(移植患者)。 这两条曲线必须从0/0开始并且会增加。

我自己的情节是通过:

pump <- read.table(file=datafile, header=FALSE,
                   col.names=c('TIME', 'CENSUS', 'DEVICE'))
# convert days to months
pump$TIME <- pump$TIME/(730/24)
mfit.overall <- survfit(Surv(TIME, CENSUS==0) ~ 1, data=pump)
plot(mfit.overall, xlab="months on device", ylab="cum. survival", xaxt="n")
axis(1, at=seq(from=0, to=24, by=6), las=0)

我该如何添加另外两条曲线?

亲切的问候约翰

样本Kaplan Meier曲线: http//i.stack.imgur.com/158e8.jpg

演示数据:

生存数据,进入泵:

 TIME CENSUS DEVICE 426 1 1 349 1 1 558 1 1 402 1 1 12 0 1 84 0 1 308 1 1 174 1 1 315 1 1 734 1 1 544 1 2 1433 1 2 1422 1 2 262 1 2 318 1 2 288 1 2 1000 1 2 

TX数据:

 TIME CENSUS DEVICE 426 1 1 288 1 2 308 1 1 

死亡人数:

 TIME CENSUS DEVICE 12 0 1 84 0 1 

使用par(new=TRUE)您可以在与第一个相同的图中绘制第二个图。

通常我会建议使用lines()将曲线添加到绘图中,因为par(new=TRUE)执行覆盖绘图的不同的任务。 当以某种方式使用函数时,它们不会被用于冒险, 例如我几乎忘记了重要的xlim参数。 然而,从survfit物体中提取曲线并survfit ,因此我认为它是两个邪恶中较小的一个。

# Fake data for the plots
pump <- data.frame(TIME=rweibull(40, 2, 20),
                   CENSUS=runif(40) < .3,
                   DEVICE=rep(0:1, c(20,20)))
# load package
library("survival")

# Fit models
mfit.overall <-survfit(Surv(TIME, CENSUS==0) ~ 1, data=pump)
mfit.htx <- survfit(Surv(TIME, CENSUS==0) ~ 1, data=pump, subset=DEVICE==1)

# Plot
plot(mfit.overall, col=1, xlim=range(pump$TIME), fun=function(x) 1-x)
# `xlim` makes sure the x-axis is the same in both plots
# `fun` flips the curve to start at 0 and increase
par(new=TRUE)
plot(mfit.htx, col=2, xlim=range(pump$TIME), fun=function(x) 1-x,
    ann=FALSE, axes=FALSE, bty="n") # This hides the annotations of the 2nd plot
legend("topright", c("All", "HTX"), col=1:2, lwd=1)

在此输入图像描述

不需要plot.new() (尽管这是该范例的一个很好的插图)。 这可以通过类"surfit"lines()方法实现。

plot(mfit.overall, col=1, xlim=range(pump$TIME), fun=function(x) 1-x)
lines(mfit.htx, col=2, fun=function(x) 1-x)
lines(mfit.htx, col=2, fun=function(x) 1-x, lty = "dashed", conf.int = "only")
legend("topleft", c("All", "HTX"), col=1:2, lwd=1, bty = "n")

这给出了使用@ Backlin的示例数据(但不同的种子,因此不同的数据)

在此输入图像描述

两次调用lines()是安排用虚线绘制置信区间,我无法看到一种方法将多个lty传递给lines() (有效!) lines()调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM