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

customizing theme #2

Closed
MarcinKosinski opened this Issue Feb 10, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@MarcinKosinski
Contributor

MarcinKosinski commented Feb 10, 2016

I've seen in your code that if your specify risk.table = TRUE then the gridExtra::grid.arrange function is used and one does not get a ggplot object as a result and customization is hard.
Is customization only possible through ggtheme argument? Where one has to write his own function? It also looks funny, as the output plot can not be changed, which it is contrary with ggplot customization paradigm.

That's very odd way of creating ggplot

ggsurvplot(survfit(Surv(times, patient.vital_status)~dataset,
                                     data = BRCAOV.survInfo),
                     #pval = TRUE, conf.int = TRUE,
                     risk.table = TRUE,
                     ggtheme = theme_RTCGA(base_size = 24, base_family = "serif") ,
                     break.time.by = 800,
                     palette = c("#FF9E29", "#86AA00"))

theme_RTCGA <- function(base_size, base_family){

    theme_grey(base_size = base_size, base_family = base_family) %+replace% 
        theme(axis.text = element_text(size = rel(0.8)),
                    axis.ticks = element_line(colour = "black"), 
                    legend.key = element_blank(), 
                    panel.background = element_blank(),
                    legend.background = element_blank(),
                    panel.border = element_blank(),
                    panel.grid.major = element_line(colour = "grey90", size = 0.2),
                    panel.grid.minor = element_line(colour = "grey98", size = 0.5),
                    strip.background = element_rect(fill = "grey80", colour = "grey50", size = 0.2))
}
@kassambara

This comment has been minimized.

Show comment
Hide comment
@kassambara

kassambara Feb 10, 2016

Owner

Hi Marcin,
Thank you for the feedback. I'm improving this part and will let you know when I'm done.
Best,
AK

Owner

kassambara commented Feb 10, 2016

Hi Marcin,
Thank you for the feedback. I'm improving this part and will let you know when I'm done.
Best,
AK

@kassambara

This comment has been minimized.

Show comment
Hide comment
@kassambara

kassambara Feb 12, 2016

Owner

Please, install the latest version of survminer and try the following R script:

# Fit survival curves
#++++++++++++++++++++++++++++++++++++
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)

# visualize
#++++++++++++++++++++++++++++++++++++
require(survminer)
ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
          risk.table = TRUE)

# Customize the output and then print
#++++++++++++++++++++++++++++++++++++
res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
           risk.table = TRUE)
res$table <- res$table + theme(axis.line = element_blank())
res$plot <- res$plot + labs(title = "Survival Curves")
print(res)

Best,
AK

Owner

kassambara commented Feb 12, 2016

Please, install the latest version of survminer and try the following R script:

# Fit survival curves
#++++++++++++++++++++++++++++++++++++
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)

# visualize
#++++++++++++++++++++++++++++++++++++
require(survminer)
ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
          risk.table = TRUE)

# Customize the output and then print
#++++++++++++++++++++++++++++++++++++
res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
           risk.table = TRUE)
res$table <- res$table + theme(axis.line = element_blank())
res$plot <- res$plot + labs(title = "Survival Curves")
print(res)

Best,
AK

@MarcinKosinski

This comment has been minimized.

Show comment
Hide comment
@MarcinKosinski

MarcinKosinski Feb 12, 2016

Contributor

Thanks for your work.
The output is now more familiar with the survMist:::autoplot.survfit which is no longer available on CRAN.

I think now customization is easier, but the color of cont.int can't be changed right know. Check this example.

library(RTCGA) # survivalTCGA is github only function
library(RTCGA.clinical)
library(survminer)
library(survival)
library(ggthemes)

survivalTCGA(BRCA.clinical, OV.clinical, 
                         extract.cols = "admin.disease_code") -> BRCAOV.survInfo

fit <- survfit(Surv(times, patient.vital_status)~admin.disease_code,
                             data = BRCAOV.survInfo)


# Customize the output and then print
#++++++++++++++++++++++++++++++++++++
res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
                                    risk.table = TRUE)
res$table <- res$table + theme_igray() + scale_colour_tableau()
res$plot <- res$plot + theme_igray() + scale_colour_tableau() + labs(title = "Survival Curves")
print(res)

conf_int_colors

Contributor

MarcinKosinski commented Feb 12, 2016

Thanks for your work.
The output is now more familiar with the survMist:::autoplot.survfit which is no longer available on CRAN.

I think now customization is easier, but the color of cont.int can't be changed right know. Check this example.

library(RTCGA) # survivalTCGA is github only function
library(RTCGA.clinical)
library(survminer)
library(survival)
library(ggthemes)

survivalTCGA(BRCA.clinical, OV.clinical, 
                         extract.cols = "admin.disease_code") -> BRCAOV.survInfo

fit <- survfit(Surv(times, patient.vital_status)~admin.disease_code,
                             data = BRCAOV.survInfo)


# Customize the output and then print
#++++++++++++++++++++++++++++++++++++
res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
                                    risk.table = TRUE)
res$table <- res$table + theme_igray() + scale_colour_tableau()
res$plot <- res$plot + theme_igray() + scale_colour_tableau() + labs(title = "Survival Curves")
print(res)

conf_int_colors

@kassambara

This comment has been minimized.

Show comment
Hide comment
@kassambara

kassambara Feb 12, 2016

Owner

Thank you Marcin for contributing to improve ggsurvplot function.

  • I agree with you that using +scale_colour_tableau() will change only survival curve line colors.
  • To change also conf.int fill color, don't you think that one simple solution would be to add +scale_fill_tableau()?
res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
                                    risk.table = TRUE)
res$table <- res$table + theme_igray() + scale_colour_tableau() 
res$plot <- res$plot + theme_igray() + scale_colour_tableau() +scale_fill_tableau() + labs(title = "Survival Curves")
print(res)
Owner

kassambara commented Feb 12, 2016

Thank you Marcin for contributing to improve ggsurvplot function.

  • I agree with you that using +scale_colour_tableau() will change only survival curve line colors.
  • To change also conf.int fill color, don't you think that one simple solution would be to add +scale_fill_tableau()?
res <- ggsurvplot(fit, pval = TRUE, conf.int = TRUE,
                                    risk.table = TRUE)
res$table <- res$table + theme_igray() + scale_colour_tableau() 
res$plot <- res$plot + theme_igray() + scale_colour_tableau() +scale_fill_tableau() + labs(title = "Survival Curves")
print(res)
@MarcinKosinski

This comment has been minimized.

Show comment
Hide comment
@MarcinKosinski

MarcinKosinski Feb 13, 2016

Contributor

Hi. I am not contributing. I didn't change even a line of your code :)
Sure I had to change fill! Thanks for pointing this out

Contributor

MarcinKosinski commented Feb 13, 2016

Hi. I am not contributing. I didn't change even a line of your code :)
Sure I had to change fill! Thanks for pointing this out

kassambara pushed a commit that referenced this issue Mar 23, 2016

kassambara pushed a commit that referenced this issue Feb 1, 2017

kassambara pushed a commit that referenced this issue Apr 16, 2017

Merge pull request #2 from kassambara/master
Merge master with MarcinKosinski::fork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment