Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-customization warnings #11

Closed
MarcinKosinski opened this Issue Feb 22, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@MarcinKosinski
Copy link
Contributor

commented Feb 22, 2016

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 scale functions in the theme argument of ggsurvplot?

Thanks in advance.

@kassambara

This comment has been minimized.

Copy link
Owner

commented Feb 23, 2016

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)

Thanks,
A. Kassambara

@MarcinKosinski

This comment has been minimized.

Copy link
Contributor Author

commented Feb 23, 2016

Thanks. Could you link to fix-commit?
You can also mention issue in the commit message like fix for #11 and this commit will appear in the workflow of this issue.

kassambara pushed a commit that referenced this issue Jan 15, 2017

Merge pull request #11 from kassambara/master
Merge pull request #107 from MarcinKosinski/master

kassambara pushed a commit that referenced this issue Mar 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.