kassambara / survminer

Survival Analysis and Visualization
https://rpkgs.datanovia.com/survminer/
504 stars 162 forks source link

Simplifying ggsurvplot #154

Closed kassambara closed 7 years ago

kassambara commented 7 years ago

Now ggsurvplot() returns list, which can contain four components:

ggsurv$plot # survival curves
ggsurv$table # risk table
ggsurv$cumevents # cumulative number of events
ggsurv$ncensor.plot # ncensor plot

Adding extra arguments in ggsurvplot(), to change the graphical parameters - title, subtitle, caption and font - of each of these components, will make the ggsurvplot() doc hard to read.

For any hyper-customization of ggsurvplot components, users should use either the function ggplot2::labs() or the function ggpubr::ggpar() as demontrated in the README file.

the function ggpar() provides, with less typing, a convenient way to play with fonts and palettes (custom color, RColorBrewer and ggsci color palettes)

kassambara commented 7 years ago

Backward compatibility will be preserved with upcoming changes

kassambara commented 7 years ago

Creating the ggrisktable() helper function to make ggsurvplot() cleaner. Normally, users don't need to use this function directly. Internally used by the ggsurvplot() function

kassambara commented 7 years ago

New function ggrisktable() added

# Fit survival curves
library(survival)
fit2 <- survfit( Surv(time, status) ~ rx + adhere,
                 data = colon )

# Plotting the survival curves
library(survminer)
ggrisktable(fit2, data = colon,  color = "strata", palette = "jco")

rplot03

kassambara commented 7 years ago

Now, the output of ggsurvplot() can look like this:


library(survival)
fit <- survfit( Surv(time, status) ~ sex,
                 data = lung )

library(survminer)
ggsurvplot(fit, data = lung,
           risk.table = TRUE,
           risk.table.title = "No at Risk",
           cumevents = TRUE,
           cumevents.title = "Cumulative No of Events",
           ncensor.plot = TRUE,
           ncensor.plot.title = "No of Censored Subjects",
           palette = "jco",
           risk.table.height = 0.2,
           cumevents.height = 0.2,
           ncensor.plot.height = 0.2
           )

rplot

The ncensor plot, based on raw timing, is not easy to read. This can be even more difficult in the situation, where the number of strata >= 3. To resolve this problem, @pbiecek implement a very convenient solution in ggsurvevents().

One could also display the cumulative number of censored subjects as a table.

kassambara commented 7 years ago

Now, it's possible to display the cumulative number of censoring. Examples are provided at https://github.com/kassambara/survminer/issues/155

kassambara commented 7 years ago

Symplifying test name in .get_pvalue()


method <- "Log-rank (survdiff)"

    test_name <- c("Log-rank (comp)", "Gehan-Breslow (generalized Wilcoxon)",
                   "Tarone-Ware", "Peto-Peto's modified survival estimate",
                   "modified Peto-Peto (by Andersen)", "Fleming-Harrington (p=1, q=1)")
kassambara commented 7 years ago

Suggestion:

method <- "Log-rank"

test_name <- c("Log-rank", "Gehan-Breslow",
               "Tarone-Ware", "Peto-Peto",
               "modified Peto-Peto", "Fleming-Harrington (p=1, q=1)")