element_text()issues a warning when vectorized arguments are provided, as in colour = c(“red”, “green”, “blue”). This is a breaking change affecting the function
ggsurvtable(). To fix this, the function
ggtext::element_markdown()is now used in place of
element_text()to handle vectorized colors (issue #455 fixed by pull #503).
survfit(res.cox)returned an object of class survfit.cox. The class has been changed to
survfitcoxin the current survival package version. The survminer package has been now updated to take this change into account (@edvbb, #441).
ggsurvplot()function. To fix this issue, Now, NAs are removed by default when drawing the confidence interval (#443 and #315).
ggflexsurvplot() to create ggplot2-based graphs for flexible survival models.
ggadjustedcurves() handles now argument
method that defines how adjusted curves shall be calculated. With
method='conditional'|'marginal' subpopulations are balanced with respect to variables present in the model formula. With
method='single'|'average' the curve represents just the expected survival curves.
The grouping variable to the
ggadjustedcurves() function is now passed as a name (character) of grouping variable not as a vector with values of grouping variable.
ggsurvtable() to change the font family in the survival tables - such as risk, cummulative events and censoring tables. For example font.family = “Courier New” (@Swechhya, #245).
test.for.trend added in
ggsurvplot() to perform a log-rank test for trend. logical value. Default is FALSE. If TRUE, returns the test for trend p-values. Tests for trend are designed to detect ordered differences in survival curves. That is, for at least one group. The test for trend can be only performed when the number of groups is > 2 (#188).
add.all added now in
ggsurvplot() to add he survival curves of (all) pooled patients onto the main survival plot stratified by grouping variables. Alias of the
ggsurvplot_add_all() function (#194).
The standard convention of ggplot2 is to have the axes offset from the origin. This can be annoying with Kaplan-Meier plots. New argument
axes.offset added non in
ggsurvplot(). logical value. Default is TRUE. If FALSE, set the plot axes to start at the origin (c(0,0)) (#196).
ggsurvplot(), one can specify pval = TRUE/FALSE as a logical value. Now, it’s also possible to specify the argument
pval as a numeric value (e.g.: pval = 0.002), that will be passed to the plot, so that user can pass any custom p-value to the final plot (@MarcinKosinski, #189) or one can specify it as a character string (e.g.: pval = “p < 0001”) (@MarcinKosinski, #193).
ggsurvplot(): numeric or character value specifying x-axis scale.
conf.int.alpha added in
ggsurvplot(). Numeric value specifying fill color transparency. Value should be in [0, 1], where 0 is full transparency and 1 is no transparency.
surv_group_by() added to create a grouped data set for survival analysis.
ggsurvplot_df() added. An extension to ggsurvplot() to plot survival curves from any data frame containing the summary of survival curves as returned the surv_summary() function. Might be useful for a user who wants to use ggsurvplot for visualizing survival curves computed by another method than the standard survfit.formula function. In this case, the user has just to provide the data frame containing the summary of the survival analysis.
surv_pvalue() added to compute p-value from survfit objects or parse it when provided by the user. Survival curves are compared using the log-rank test (default). Other methods can be specified using the argument method.
surv_fit() added to handle complex situation when computing survival curves (Read more in the doc: ?surv_fit). Wrapper arround the standard
survfit() [survival] function to create survival curves. Compared to the standard survfit() function, it supports also:
ggcompetingrisks() supports the
conf.int argument. If
fit is an object of class
cuminc then confidence intervals are plotted with
For example, in the following script, survival curves are colored by the grouping variable
sex in all facets:
library(survminer) library(survival) fit <- survfit( Surv(time, status) ~ sex + rx + adhere, data = colon ) ggsurv <- ggsurvplot(fit, data = colon, color = "sex", legend.title = "Sex", palette = "jco") ggsurv$plot + facet_grid(rx ~ adhere)
Now, the function
pairwise_survdiff() checks whether the grouping variable is a factor. If this is not the case, the grouping variable is automatically converted into a factor.
ggcoxdiagnostics()function and the vignette file
Informative_Survival_Plots.Rmdhave been updated so that
survminercan pass CRAN check under R-oldrelease.
BMTadded for competing risk analysis.
BRCAOV.survInfoadded, used in vignette files
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).
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”.
tables.height, tables.y.text, tables.theme, tables.col: for customizing tables under the main survival plot: (#156).
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'.
log.rank.weights: New possibilities to compare survival curves. Functionality based on
break.y.by, numeric value controlling x and y axis breaks, respectively.
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.
+.ggsurv()to add ggplot components -
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") )
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).
ggforest() for drawing forest plot for the Cox model.
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).
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").
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")
ggcoxdiagnostics(), the option
ncol = 1is 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.
surv_summary() (v0.2.3) generated an error when the name of the variable used in
survfit() can be found multiple times in the levels of the same variable. For example, variable = therapy; levels(therapy) –> “therapy” and “hormone therapy” (#86). This has been now fixed.
To extract variable names used in
survival::survfit(), the R code
strsplit(strata, "=|,\\s+", perl=TRUE) was used in the
surv_summary() function [survminer v0.2.3]. The splitting was done at any “=” symbol in the string, causing an error when special characters (=, <=, >=) are used for the levels of a categorical variable (#91). This has been now fixed.
surv_summary()for creating data frame containing a nice summary of a survival curve (#64).
ggsurvplot()by one or more factors (#64):
# Fit complexe survival curves require("survival") fit3 <- survfit( Surv(time, status) ~ sex + rx + adhere, data = colon ) # Visualize by faceting # Plots are survival curves by sex faceted by rx and adhere factors. require("survminer") ggsurv$plot +theme_bw() + facet_grid(rx ~ adhere)
ggsurvplot()can be used to plot cox model (#67).
ggsurvplot(). A logical value. If TRUE, the number of censored subjects at time t is plotted. Default is FALSE (#18).
ggsurvplot()for changing the style of confidence interval bands.
ggsurvplot()plots a stepped confidence interval when conf.int = TRUE (#65).
ggsurvplot()updated for compatibility with the future version of ggplot2 (v2.2.0) (#68)
fun. For example, if fun = “event”, then ylab will be “Cumulative event”.
ggsurvplot(), linetypes can now be adjusted by variables used to fit survival curves (#46)
ggsurvplot(), the argument risk.table can be either a logical value (TRUE|FALSE) or a string (“absolute”, “percentage”). If risk.table = “absolute”,
ggsurvplot()displays the absolute number of subjects at risk. If risk.table = “percentage”, the percentage at risk is displayed. Use “abs_pct” to show both the absolute number and the percentage of subjects at risk (#70).
ggsurvplot(): character vector for drawing a horizontal/vertical line at median (50%) survival. Allowed values include one of c(“none”, “hv”, “h”, “v”). v: vertical, h:horizontal (#61).
ggcoxdiagnostics()can now handle a multivariate Cox model (#62)
ggcoxfunctional()now displays graphs of continuous variable against martingale residuals of null cox proportional hazards model (#63).
ggsurvplot()to report the right p-value on the subset of the data and not on the whole data sets (@jseoane, #71).
ggcoxzph()can now produce plots only for specified subset of varibles (@MarcinKosinski, #75)
ggcoxdiagnosticsfunction that plots diagnostic graphs for Cox Proportional Hazards model (@MarcinKosinski, #16).
Survival plots have never been so informative(@MarcinKosinski, #39)
ggcoxfunctional function that displays graphs of continuous explanatory variable against martingale residuals of null cox proportional hazards model, for each term in of the right side of input formula. This might help to properly choose the functional form of continuous variable in cox model, since fitted lines with
lowess function should be linear to satisfy cox proportional hazards model assumptions. (@MarcinKosinski, #14)
theme_classic2: ggplot2 classic theme with axis line. This function replaces ggplot2::theme_classic, which does no longer display axis lines (since ggplot2 v2.1.0)
risk.table.y.text.colis now TRUE.
ggsurvplot. logical argument. Default is TRUE. If FALSE, risk table y axis tick labels will be hidden (@MarcinKosinski, #28).
New arguments in ggsurvplot for changing font style, size and color of main title, axis labels, axis tick labels and legend labels: font.main, font.x, font.y, font.tickslab, font.legend.
New arguments risk.table.title, risk.table.fontsize in ggsurvplot
print.ggsurvplot() function added: S3 method for class ‘ggsurvplot’.
ggsurvplot returns an object of class ggsurvplot which is list containing two ggplot objects:
# Fit survival curves require("survival") fit<- survfit(Surv(time, status) ~ sex, data = lung) # visualize require(survminer) ggsurvplot(fit, pval = TRUE, conf.int = TRUE, risk.table = TRUE) # Customize the output and then print res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE, risk.table = TRUE) res$table <- res$table + theme(axis.line = element_blank()) res$plot <- res$plot + labs(title = "Survival Curves") print(res)
xlim changed to cartesian coordinates mode (@MarcinKosinski, #4). The Cartesian coordinate system is the most common type of coordinate system. It will zoom the plot (like you’re looking at it with a magnifying glass), without clipping the data.
Risk table and survival curves have now the same color and the same order