vsd: Visualizing Survival Data

Description Usage Arguments Details Value Methods (by class) Generic graphical arguments Examples

View source: R/vsd.R

Description

This function outputs renders of the inputted survival data analysis data and/or model, and their components, into a graphically pleasing output, under the ggplot2 format.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "parametric", "forest", "residuals", "hazard"),
  .arguments = list(),
  ...
)

## S3 method for class 'formula'
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "hazard"),
  .arguments = list(),
  ...
)

## S3 method for class 'Surv'
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "hazard"),
  .arguments = list(),
  ...
)

## S3 method for class 'coxph'
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "forest", "residuals", "hazard"),
  .arguments = list(),
  ...
)

## S3 method for class 'survfit'
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "hazard"),
  .arguments = list(),
  ...
)

## S3 method for class 'survfitcox'
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "forest", "residuals", "hazard"),
  .arguments = list(),
  ...
)

## S3 method for class 'flexsurvreg'
vsd(
  model,
  data = NULL,
  .interactive = FALSE,
  .include = c("fit", "parametric", "hazard"),
  .arguments = list(),
  ...
)

Arguments

model

The survival model, or data structure, to generate graphics from

data

Dataframe from where the model fetches its variables, if left blank will be extracted from the model, if possible

.interactive

Allows to explore the generated graphs before returning (use with plotly package for best results)

.include

Graph types to output if relevant, defaults to all possible

.arguments

Collection of list of arguments, indexed by the specific type of graph they should be passed to, has priority over ...

...

Miscellaneous arguments, passed to ALL graphs

Details

Depending on the kind of model passed to the function, the kind of generated graphics might vary, but usually an estimation of the survival and risk curves (depending if the model has covariables) is expected. The kinds of graphics that can be created according to a specific R object are detailed on Usage on .include's definition, but non-relevant graphics can be requested without error, as the function ignores them silently.

Extra options for each graph kind can be passed to either all created graphics, by having them as generic arguments, or to specific graphic types, using a list in .arguments. Arguments are filtered, so that generic arguments aren't applied if a graphic kind wouldn't use them. As an example,

1
2
3
vsd(model, data, 
    .arguments = list(fit = (size = 3, xlab = "Weeks")),
    xlab = "Days") 

would set all graphics that have an label on the x axis to "Days", except the fit graph, which would have "Weeks" instead.

Value

A list of ggplot2 graphs and/or list of graphs, relevant to the model

Methods (by class)

Generic graphical arguments

Unless specified, all graphics are created under ggpubr::ggpar() and have as additional options palette, main, submain, xlab, ylab, legend.title and ggtheme. Most line graphics also allow to set the options size, linetype, alpha and color to determine line styles, as detailed on survminer::ggsurvplot().

fit

Line graphic, with a further subset of the options present in survminer::ggsurvplot(): censor, censor.shape, censor.size, conf.int, conf.int.style.

parametric

Line graphic, with a further subset of the options present in survminer::ggflexsurvplot(): conf.int.km.

forest

Non-standard graphic(s), using all options within survminer::ggforest(): main, cpositions, fontsize, refLabel, noDigits.

residuals

Line graphic(s), with a further subset of options present in survminer::ggcoxzph(): resid, se, df, nsmo, var, caption; and point style customization options as point.col, point.size, point.shape, and point.alpha.

hazard

Line graphics, using the generic graphical arguments.

Examples

1
2
3
4
5
6
7
# non-models are cohersed into a survfit object with default arguments
vsd(coxph(Surv(time, status) ~ sex + strata(rx) + adhere, data = colon), 
    .include = c("haz"))

# parametric models are also supported with flexsurv
vsd(flexsurv::flexsurvreg(Surv(rectime, censrec) ~ group, data = flexsurv::bc, dist = 'gengamma'),
    .include = c("par"))

vsd documentation built on May 11, 2021, 5:07 p.m.