Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # How to build informative survival plots
- # source: http://r-addict.com/2016/05/23/Informative-Survival-Plots.html
- # setup
- install.packages('survminer')
- source("https://bioconductor.org/biocLite.R")
- biocLite("RTCGA.clinical") # data for examples
- Plot the difference in survival times between patients suffering from Ovarian Cancer & Breast Cancer using data collected by The Cancer Genome Atlas Project.
- library(RTCGA.clinical)
- survivalTCGA(BRCA.clinical, OV.clinical, extract.cols = "admin.disease_code") -> BRCAOV.survInfo
- library(survival)
- fit <- survfit(Surv(times, patient.vital_status) ~ admin.disease_code, data = BRCAOV.survInfo)
- library(survminer)
- ggsurvplot(fit, risk.table = TRUE)
- Improved version with parameters:
- ggsurvplot(
- fit, # survfit object with calculated statistics.
- risk.table = TRUE, # show risk table.
- pval = TRUE, # show p-value of log-rank test.
- conf.int = TRUE, # show confidence intervals for
- # point estimaes of survival curves.
- xlim = c(0,2000), # present narrower X axis, but not affect
- # survival estimates.
- break.time.by = 500, # break X axis in time intervals by 500.
- ggtheme = theme_RTCGA(), # customize plot and risk table with a theme.
- risk.table.y.text.col = T, # colour risk table text annotations.
- risk.table.y.text = FALSE # show bars instead of names in text annotations
- # in legend of risk table
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement