Title: | Graphical Shim for Visual Survival Data Analysis |
---|---|
Description: | Provides a shim command for survival analysis graphic generation. |
Authors: | Daniel Camacho [aut, cre] |
Maintainer: | Daniel Camacho <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-02-14 04:12:51 UTC |
Source: | https://github.com/cyanzule/vsd |
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.
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(), ... )
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(), ... )
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 |
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,
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.
A list of ggplot2 graphs and/or list of graphs, relevant to the model
formula
: Wraps Surv(...) ~ (...)
in a survfit object (Kaplan-Meier
model)
Surv
: Wraps Surv()
in a survfit object (Kaplan-Meier
model)
coxph
: Wraps coxph(...)
in a survfit object (Kaplan-Meier
model)
survfit
: Graphical output for survfit objects (Kaplan-Meier model)
survfitcox
: Graphical output for survfit objects (Cox model)
flexsurvreg
: Graphical output for flexsurvreg objects (various parametric models)
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()
.
Line graphic, with a further subset of the options present in
survminer::ggsurvplot()
: censor
, censor.shape
, censor.size
,
conf.int
, conf.int.style
.
Line graphic, with a further subset of the options present in
survminer::ggflexsurvplot()
: conf.int.km
.
Non-standard graphic(s), using all options within survminer::ggforest()
:
main
, cpositions
, fontsize
, refLabel
, noDigits
.
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
.
Line graphics, using the generic graphical arguments.
# non-models are cohersed into a survfit object with default arguments vsd(Surv(time, status) ~ ph.ecog, data=lung, .include = c("fit", "haz")) # coxph (with and without strata) vsd(coxph(Surv(time, status) ~ sex + strata(rx) + adhere, data = colon), .include = c("res")) # parametric models vsd(flexsurv::flexsurvreg(Surv(rectime, censrec) ~ group, data = flexsurv::bc, dist = 'gengamma'), .include = c("par"))
# non-models are cohersed into a survfit object with default arguments vsd(Surv(time, status) ~ ph.ecog, data=lung, .include = c("fit", "haz")) # coxph (with and without strata) vsd(coxph(Surv(time, status) ~ sex + strata(rx) + adhere, data = colon), .include = c("res")) # parametric models vsd(flexsurv::flexsurvreg(Surv(rectime, censrec) ~ group, data = flexsurv::bc, dist = 'gengamma'), .include = c("par"))