ggsurvplot_patchwork: Convert a ggsurvplot to a patchwork

View source: R/gg_survplot_patchwork.R

ggsurvplot_patchworkR Documentation

Convert a ggsurvplot to a patchwork

Description

A thin wrapper around survminer::ggsurvplot() that creates a survival plot and risk table, converts plots to a patchwork (see patchwork::patchwork), and applies some custom formatting options.

Usage

ggsurvplot_patchwork(fit, scibeautify = T, axis.title.y.nudge = 0, ...)

Arguments

fit

allowed values include:

  • a survfit object

  • a list of survfit objects. Passed to ggsurvplot_list()

  • a data frame containing survival curves summary. Passed to ggsurvplot_df().

scibeautify

Whether to apply scibeautify() to the numbers in the risk table

axis.title.y.nudge

Custom right-margin for the y-axis title of the plot, in units of "lines"

...

Arguments passed on to survminer::ggsurvplot

data

a dataset used to fit survival curves. If not supplied then data will be extracted from 'fit' object.

fun

an arbitrary function defining a transformation of the survival curve. Often used transformations can be specified with a character argument: "event" plots cumulative events (f(y) = 1-y), "cumhaz" plots the cumulative hazard function (f(y) = -log(y)), and "pct" for survival probability in percentage.

color

color to be used for the survival curves.

  • If the number of strata/group (n.strata) = 1, the expected value is the color name. For example color = "blue".

  • If n.strata > 1, the expected value is the grouping variable name. By default, survival curves are colored by strata using the argument color = "strata", but you can also color survival curves by any other grouping variables used to fit the survival curves. In this case, it's possible to specify a custom color palette by using the argument palette.

palette

the color palette to be used. Allowed values include "hue" for the default hue color scale; "grey" for grey color palettes; brewer palettes e.g. "RdBu", "Blues", ...; or custom color palette e.g. c("blue", "red"); and scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", "lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty". See details section for more information. Can be also a numeric vector of length(groups); in this case a basic color palette is created using the function palette.

linetype

line types. Allowed values includes i) "strata" for changing linetypes by strata (i.e. groups); ii) a numeric vector (e.g., c(1, 2)) or a character vector c("solid", "dashed").

conf.int

logical value. If TRUE, plots confidence interval.

pval

logical value, a numeric or a string. If logical and TRUE, the p-value is added on the plot. If numeric, than the computet p-value is substituted with the one passed with this parameter. If character, then the customized string appears on the plot. See examples - Example 3.

pval.method

whether to add a text with the test name used for calculating the pvalue, that corresponds to survival curves' comparison - used only when pval=TRUE

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.

surv.median.line

character vector for drawing a horizontal/vertical line at median survival. Allowed values include one of c("none", "hv", "h", "v"). v: vertical, h:horizontal.

risk.table

Allowed values include:

  • TRUE or FALSE specifying whether to show or not the risk table. Default is FALSE.

  • "absolute" or "percentage". Shows the absolute number and the percentage of subjects at risk by time, respectively.

  • "abs_pct" to show both absolute number and percentage.

  • "nrisk_cumcensor" and "nrisk_cumevents". Show the number at risk and, the cumulative number of censoring and events, respectively.

cumevents

logical value specifying whether to show or not the table of the cumulative number of events. Default is FALSE.

cumcensor

logical value specifying whether to show or not the table of the cumulative number of censoring. Default is FALSE.

tables.height

numeric value (in [0 - 1]) specifying the general height of all tables under the main survival plot.

group.by

a character vector containing the name of grouping variables. Should be of length <= 2. Alias of the ggsurvplot_group_by() function.

facet.by

a character vector containing the name of grouping variables to facet the survival curves into multiple panels. Should be of length <= 2. Alias of the ggsurvplot_facet() function.

add.all

a logical value. If TRUE, add the survival curve of pooled patients (null model) onto the main plot. Alias of the ggsurvplot_add_all() function.

combine

a logical value. If TRUE, combine a list survfit objects on the same plot. Alias of the ggsurvplot_combine() function.

ggtheme

function, ggplot2 theme name. Default value is theme_survminer. Allowed values include ggplot2 official themes: see theme.

tables.theme

function, ggplot2 theme name. Default value is theme_survminer. Allowed values include ggplot2 official themes: see theme. Note that, tables.theme is incremental to ggtheme.

Value

A patchwork


adamleejohnson/R-ajtools documentation built on April 4, 2022, 7:24 a.m.