Site icon R-bloggers

When You Went too Far with Survival Plots During the survminer 1st Anniversary

[This article was first published on http://r-addict.com, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We are celebrating the 1st anniversary of the survminer’s release on CRAN! Due to that fact I have prepared the most (uber platinum) customized survival plot that I could imagine. I went too far because it took over 30 parameters to create a graph..

survminer, a package for drawing easily beautiful and ‘ready-to-publish’ survival curves with the ‘number at risk’ table and ‘censoring count plot’, has became very popular at the end of a previous year. It happend due to 3 great methodology posts about Cox Proportional Hazards model and Survival Analysis basics by Alboukadel Kassambara (kassambara) published on STDHA

If you are working in the survival analysis field, you might be interested in reading the post covering the newest features in survminer: survminer 0.2.4

Right now, after a year of the first CRAN release, survminer has been downloaded 11k times and has been used and cited in several research articles:

Due to the celebration of it’s 1st anniversary on CRAN, I have prepared a long survival graph of Kaplan-Meier estimates of survival curves, where each option is described below. I think I went too far to present the possible customization of the graph because this example takes over 30 parameters!

       
   ggsurvplot(
   fit,                     # survfit object with calculated statistics.
   risk.table = TRUE,       # show risk table.
   pval = TRUE,             # show p-value of log-rank test.
   conf.int = TRUE,         # show confidence intervals for 
                            # point estimaes of survival curves.
   xlim = c(0,500),         # present narrower X axis, but not affect
                            # survival estimates.
   xlab = "Time in days",   # customize X axis label.
   break.time.by = 100,     # break X axis in time intervals by 500.
   ggtheme = theme_light(), # customize plot and risk table with a theme.
  risk.table.y.text.col = T,# colour risk table text annotations.
  risk.table.y.text = FALSE,# show bars instead of names in text annotations
                            # in legend of risk table.
  ncensor.plot = TRUE,      # plot the number of censored subjects at time t
  conf.int.style = "step",  # customize style of confidence intervals
  surv.median.line = "hv",  # add the median survival pointer.
  legend.labs = 
    c("Male", "Female"),    # change legend labels.
  palette = 
    c("#E7B800", "#2E9FDF"),# custom color palettes.
  main = "Survival curves",                       # specify the title of the plot
  submain = "Based on Kaplan-Meier estimates",    # the subtitle of the plot 
  caption = "created with survminer",             # the caption of the plot
  .main = c(16, "bold", "darkblue"),          #  for titles of the plot, the table and censor part
  .submain = c(15, "bold.italic", "purple"),  #  for subtitles in the plot, the table and censor part
  .caption = c(14, "plain", "orange"),        #  for captions in the plot, the table and censor part
  .x = c(14, "bold.italic", "red"),           #  for x axises in the plot, the table and censor part
  .y = c(14, "bold.italic", "darkred"),       #  for y axises in the plot, the table and censor part
  .tickslab = c(12, "plain", "darkgreen"),    #  for ticklabs in the plot, the table and censor part
  ########## risk table #########,
  risk.table.title = "Note the risk set sizes",          # the title of the risk table
  risk.table.subtitle = "and remember about censoring.", # the subtitle of the risk table
  risk.table.caption = "source code: website.com",       # the caption of the risk table
  risk.table.height = 0.35,                              # the height of the risk table
  ########## ncensor plot ######
  ncensor.plot.title = "Number of censorings",           # as above but for the censoring plot
  ncensor.plot.subtitle = "over the time.",
  ncensor.plot.caption = "data available at data.com",
  ncensor.plot.height = 0.35)
       

To leave a comment for the author, please follow the link and comment on their blog: http://r-addict.com.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.