Is there a way to add tick/censor marks to cumulative incidence plot in R?

101 views Asked by At

I am interested in generating a cumulative incidence plot for competing events that includes tick/censor marks in the curves. I know you can create plots with tick/censor marks using 1-CSH kaplan meier method in the absence of competing risk, but this seems to overestimate the risk probability over time. I am wondering if anyone knows of a way to add tick/censor marks to cumulative incidence plot (see cuminc() plot below) in the presence of competing risks or knows of a package that can account for competing events and adds tick/censor marks. I have been googling around for some time and I haven't found a way to do so. As far as I know, there is not a way to do this currently. Any help would be appreciated. :)

Here are some posts I have seen:

I have looked into documentation for plot(cuminc()) and ggcompetingrisks(ci.cuminc), but haven't seen of a parameter to include tick/censor marks onto the curves.

In the example below, I use the survival ovarian dataset and add an additional event by replacing the fustat with 2 if their futime survival time was < 300.

library(survival)
library(survminer)
library(cmprsk)
library(ggsurvfit)

df <- data.frame(ovarian)
df$fustat2 <- df$fustat
df[df$futime < 300,]$fustat2 <- 2

df$rx <- factor(df$rx, c(1, 2), labels=c('Rx1', 'Rx2'))

# This example is 1-CS KM:
surv.obj <- survfit(Surv(futime, fustat2==1)~rx, data=df)
#plot(surv.obj, fun= function(x) {1 - x}, bty='L', mark.time=TRUE)
plot(surv.obj,  fun="event",              bty='L', mark.time=TRUE)

enter image description here

# ggsurvfit also produces 1-CS KM curve:
ggsurvfit(surv.obj, type = "risk") + add_censor_mark()

enter image description here

# Cumulative incidence Curve:
ci.cuminc <- cuminc(ftime = df$futime, fstatus= df$fustat2, group =  df$rx)

plot(ci.cuminc, lty=c(1, 1, 0, 0), wh=c(-1,-1), ylim=c(0, 0.45))

enter image description here

# Survminer package has ggcompetingrisks()
ggpar(ggcompetingrisks(ci.cuminc[1:2], multiple_panels = FALSE, censor=TRUE, censor.shape="+"), ylab = "Probablity")

enter image description here

1

There are 1 answers

1
Daniel D. Sjoberg On BEST ANSWER

You can do this with the ggsurvfit package. You'll want to use tidycmprsk::cuminc() to estimate the CIF, the use ggsurvfit::ggcuminc() to plot the risk curves. The package exports a ggsurvfit::add_censor_mark() function to add the censoring indicators.

In the example below, all subjects were censored at the same time (24 months) if they hadn't died from cancer, so all the marks appear at the same spot. It would look more interesting with a more interesting censoring distribution.

library(ggsurvfit)
#> Loading required package: ggplot2
library(tidycmprsk)

cuminc(Surv(ttdeath, death_cr) ~ trt, trial) %>%
  ggcuminc(outcome = "death from cancer") +
  add_censor_mark(size = 5) +
  scale_ggsurvfit(x = list(breaks = seq(0, 24, by = 6)))

Created on 2024-01-25 with reprex v2.0.2