Join GitHub today
Post-customization warnings #11
Relating to #2 I am trying to post-customize the result theme of the survplot but it looks like colour and fill and pre-determined so post-customization triggers warnings like this
> # prepare survival data > library(RTCGA.clinical) Loading required package: RTCGA Welcome to the RTCGA (version: 1.1.14). > survivalTCGA(BRCA.clinical, OV.clinical, extract.cols = "admin.disease_code") -> BRCAOV.survInfo > times = "times" > status = "patient.vital_status" > explanatory.names = "admin.disease_code" > x = BRCAOV.survInfo > > # fit survival estimates > library(survival) > formu <- eval(as.formula(paste0("survival::Surv(", times, ",", status, ") ~ ", + paste0(explanatory.names, collapse = " + ")))) > fit <- do.call(survival::survfit, list(formula = formu, data = x)) > library(survminer) Loading required package: ggplot2 > # create survival plot > ggsurvplot(fit, + risk.table = TRUE, + risk.table.y.text.col = TRUE, + legend = "none", + conf.int = TRUE, + pval = TRUE) -> survplot > # customize theme > library(ggthemes) > survplot$table <- survplot$table + scale_fill_pander() + scale_colour_pander() Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale. > survplot$plot <- survplot$plot + scale_fill_pander() + scale_colour_pander() Scale for 'fill' is already present. Adding another scale for 'fill', which will replace the existing scale. Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale.
I know that this warning messages are not serious but I would like to know how to omit those warnings in case someone not skilled might think it's a serious problem. Do you know whether I can specify parameters of ggsurvplot so that I would not have such warnings? Or do I can somehow specify those
Thanks in advance.
Minor changes added to ggsurplot() now. Post-customization of color and fill no longer shows warnings.
# Fit survival curves library("survival") fit<- survfit(Surv(time, status) ~ sex, data = lung) # Default plot p <- ggsurvplot(fit, risk.table = TRUE, pval = TRUE, risk.table.y.text.col = TRUE) print(p) # Customize p$plot <- p$plot + ggthemes::scale_color_pander() print(p)