Skip to content

survminer 0.3.0

Compare
Choose a tag to compare
@kassambara kassambara released this 16 Mar 09:08
· 358 commits to master since this release

New features

New options in ggsurvplot()

  • Additional data argument added to the ggsurvplot() function (@kassambara, #142). Now, it's recommended to pass to the function, the data used to fit survival curves. This will avoid the error generated when trying to use the ggsurvplot() function inside another functions (@zzawadz, #125).

  • New argument risk.table.pos, for placing risk table inside survival curves (#69). Allowed options are one of c("out", "in") indicating 'outside' or 'inside' the main plot, respectively. Default value is "out".

  • New arguments tables.height, tables.y.text, tables.theme, tables.col: for customizing tables under the main survival plot: (#156).

  • New arguments cumevents and cumcensor: logical value for displaying the cumulative number of events table (#117) and the cumulative number of censored subject (#155), respectively.

  • Now, ggsurvplot() can display both the number at risk and the cumulative number of censored in the same table using the option risk.table = 'nrisk_cumcenor' (#96). It's also possible to display the number at risk and the cumulative number of events using the option risk.table = 'nrisk_cumevents'.

  • New arguments pval.method and log.rank.weights: New possibilities to compare survival curves. Functionality based on survMisc::comp.

  • New arguments break.x.by and break.y.by, numeric value controlling x and y axis breaks, respectively.

  • Now, ggsurvplot() returns an object of class ggsurvplot which is list containing the following components (#158):

    • plot: the survival plot (ggplot object)
    • table: the number of subjects at risk table per time (ggplot object). Returned only when risk.table = TRUE.
    • cumevents: the cumulative number of events table (ggplot object). Returned only when cumevents = TRUE.
    • ncensor.plot: the number of censoring (ggplot object). Returned only when ncensor.plot = TRUE or cumcensor = TRUE.
    • data.survplot: the data used to plot the survival curves (data.frame).
    • data.survtable: the data used to plot the tables under the main survival curves (data.frame).

Themes

  • New function theme_survminer() to change easily the graphical parameters of plots generated with survminer (#151). A theme similar to theme_classic() with large font size. Used as default theme in survminer functions.

  • New function theme_cleantable() to draw a clean risk table and cumulative number of events table. Remove axis lines, x axis ticks and title (#117 & #156).

# Fit survival curves
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)

# Survival curves
require("survminer")
ggsurvplot(fit, data = lung, risk.table = TRUE,
    tables.theme = theme_cleantable()
    )

New functions

  • New function +.ggsurv() to add ggplot components - theme(), labs() - to an object of class ggsurv, which is a list of ggplots. (#151). For example:
# Fit survival curves
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)

# Basic survival curves
require("survminer")
p <- ggsurvplot(fit, data = lung, risk.table = TRUE)
p

# Customizing the plots
p %+% theme_survminer(
     font.main = c(16, "bold", "darkblue"),
     font.submain = c(15, "bold.italic", "purple"),
     font.caption = c(14, "plain", "orange"),
     font.x = c(14, "bold.italic", "red"),
     font.y = c(14, "bold.italic", "darkred"),
     font.tickslab = c(12, "plain", "darkgreen")
)
  • New function arrange_ggsurvplots() to arrange multiple ggsurvplots on the same page (#66).

  • New function ggsurvevents() to calculate and plot the distribution for events (both status = 0 and status = 1); with type parameter one can plot cumulative distribution of locally smooth density; with normalised, distributions are normalised. This function helps to notice when censorings are more common (@pbiecek, #116).

  • New function ggcoxadjustedcurves() to plot adjusted survival curves for Cox proportional hazards model (@pbiecek, #133 & @markdanese, #67).

  • New function ggforest() for drawing forest plot for the Cox model.

  • New function pairwise_survdiff() for multiple comparisons of survival Curves (#97).

  • New function ggcompetingrisks() to plot the cumulative incidence curves for competing risks (@pbiecek, #168.

Helper functions

New heper functions ggrisktable(), ggcumevents(), ggcumcensor(). Normally, users don't need to use these function directly. Internally used by the function ggsurvplot().

  • ggrisktable() for plotting number of subjects at risk by time. (#154).
  • ggcumevents() for plotting the cumulative number of events table (#117).
  • ggcumcensor() for plotting the cumulative number of censored subjects table (#155).

Major changes

  • New argument sline in the ggcoxdiagnostics() function for adding loess smoothed trend on the residual plots. This will make it easier to spot some problems with residuals (like quadratic relation). (@pbiecek, #119).

  • The design of ggcoxfunctional() has been changed to be consistent with the other functions in the survminer package. Now, ggcoxfunctional() works with coxph objects not formulas. The arguments formula is now deprecated (@pbiecek, #115).

  • In the ggcoxdiagnostics() function, it's now possible to plot Time in the OX axis (@pbiecek, #124). This is convenient for some residuals like Schoenfeld. The linear.predictions parameter has been replaced with ox.scale = c("linear.predictions", "time", "observation.id").

Minor changes

  • New argument tables.height in ggsurvplot() to apply the same height to all the tables under the main survival plots (#157).

  • It is possible to specify title and caption for ggcoxfunctional (@MarcinKosinski, #138) (font.main was removed as it was unused.)

  • It is possible to specify title, subtitle and caption for ggcoxdiagnostics (@MarcinKosinski, #139) and fonts for them.

  • It is possible to specify global caption for ggcoxzph (@MarcinKosinski, #140).

  • In ggsurvplot(), more information, about color palettes, have been added in the details section of the documentation (#100).

  • The R package maxstat doesn't support very well an object of class tbl_df. To fix this issue, now, in the surv_cutpoint() function, the input data is systematically transformed into a standard data.frame format (@MarcinKosinski, #104).

  • It's now possible to print the output of the survminer packages in a powerpoint created with the ReporteRs package. You should use the argument newpage = FALSE in the print() function when printing the output in the powerpoint. Thanks to (@abossenbroek, #110) and (@zzawadz, #111). For instance:

require(survival)
require(ReporteRs)
require(survminer)

fit <- survfit(Surv(time, status) ~ rx + adhere, data =colon)
survplot <- ggsurvplot(fit, pval = TRUE,
                       break.time.by = 400,
                       risk.table = TRUE,
                       risk.table.col = "strata",
                       risk.table.height = 0.5, # Useful when you have multiple groups
                       palette = "Dark2")


require(ReporteRs)
doc = pptx(title = "Survival plots")
doc = addSlide(doc, slide.layout = "Title and Content")
doc = addTitle(doc, "First try")
doc = addPlot(doc, function() print(survplot, newpage = FALSE), vector.graphic = TRUE)
writeDoc(doc, "test.pptx")
  • Now, in ggcoxdiagnostics(), the option ncol = 1 is removed from the function facet_wrap(). By default, ncol = NULL. In this case, the number of columns and rows in the plot panels is defined automatically based on the number of covariates included in the cox model.

Bug fixes

  • Now, risk table align with survival plots when legend = "right" (@jonlehrer, #102).

  • Now, ggcoxzph() works for univariate Cox analysis (#103).

  • Now, ggcoxdiagnostics() works properly for schoenfeld residuals (@pbiecek, #119).

  • Now, ggsurvplot() works properly in the situation where strata() is included in the cox formula (#109).

Vignettes and examples

  • A new vignette and a ggsurvplot example was added to present new functionalities of possible texts and fonts customizations.

  • A new vignette and a ggsurvplot example was added to present new functionalities of possible weights specification in a Log-rank test.