Search code examples
rsurvival-analysis

How can I extract the time for specific percentiles in ggcuminc plot?


I am plotting the cumulative incidence function (CIF) and I want to be able to see the time at specific percentiles.

This is my code. I am using the tidycmprsk package and then adding the ggcuming to plot the CIF:

cif_RFS_overall <- tidycmprsk::cuminc(Surv(time, status) ~ 1, data = df) %>%  
  ggcuminc(outcome = "relapse") +
  labs(
    x = "Months"
  ) + 
  add_risktable(risktable_stats = "n.risk") +  
  scale_ggsurvfit() 

How can I for example get the time for percentile 50% or for 10%?


Solution

  • You can use add_quantile() function to provide quantile information annotated on the plot. You can indicate the numeric value where a line segment will be drawn. In this case, for 10% cumulative incidence, you can provide y_value = .1 as an argument.

    Here is a complete example using trial data. This dataset includes 200 patients who received Drug A or Drug B as well as the outcome of tumor response to the treatment.

    library(tidycmprsk)
    library(ggsurvfit)
    
    cuminc(Surv(ttdeath, death_cr) ~ trt, trial) %>%
      ggcuminc(outcome = "death from cancer") +
      add_risktable(risktable_stats = "n.risk") +
      add_quantile(y_value = .1) +
      scale_ggsurvfit()
    

    Plot

    plot of cumulative incidence with line added at 10% level