kassambara / survminer

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

error in example #315

Closed fkgruber closed 6 years ago

fkgruber commented 6 years ago

Expected behavior

generate plot

Actual behavior

complain: Error in f(...) : Aesthetics can not vary with a ribbon

Steps to reproduce the problem

require("survival") fit3 <- survfit( Surv(time, status) ~ sex + rx + adhere, data = colon )

 # Visualize
 #++++++++++++++++++++++++++++++++++++
 ggsurv <- ggsurvplot(fit3, data = colon,
   fun = "cumhaz", conf.int = TRUE,
   risk.table = TRUE, risk.table.col="strata",
   ggtheme = theme_bw())

 # Faceting survival curves
 curv_facet <- ggsurv$plot + facet_grid(rx ~ adhere)
 curv_facet

session_info()

sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.1 LTS

locale: [1] en_US.utf8

attached base packages: [1] grid parallel stats graphics grDevices utils datasets methods base

other attached packages: [1] mclust_5.3 ggfortify_0.4.1 coda_0.19-1 rentrez_1.1.0 stringdist_0.9.4.6 biomaRt_2.30.0 stringr_1.2.0
[9] survminer_0.4.2 ggpubr_0.1.6 magrittr_1.5 risksetROC_1.0.4 MASS_7.3-47 timeROC_0.3 survcomp_1.24.0 prodlim_1.6.1
[17] survival_2.41-3 pROC_1.10.0 bindrcpp_0.2 Biobase_2.34.0 BiocGenerics_0.20.0 reshape_0.8.7 codetools_0.2-15
[25] iterators_1.0.9 foreach_1.4.4 R6_2.2.2 dtplyr_0.0.2 dplyr_0.7.3 purrr_0.2.3 readr_1.1.1 tidyr_0.7.1
[33] tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1 data.table_1.10.4-3

loaded via a namespace (and not attached): [1] colorspace_1.3-2 PerfMeas_1.2.1 roxygen2_5.0.1 bit64_0.9-7 AnnotationDbi_1.36.2 mvtnorm_1.0-6 lubridate_1.6.0 xml2_1.1.1
[9] splines_3.3.2 mnormt_1.5-5 knitr_1.17 SuppDists_1.1-9.4 jsonlite_1.5 doMC_1.3.4 broom_0.4.2 km.ci_0.5-2
[17] kernlab_0.9-25 graph_1.52.0 compiler_3.3.2 httr_1.3.1 assertthat_0.2.0 Matrix_1.2-11 lazyeval_0.2.0 limma_3.30.13
[25] tools_3.3.2 modeest_2.1 igraph_1.1.2 gtable_0.2.0 glue_1.1.1 reshape2_1.4.3 Rcpp_0.12.13 SuperLearner_2.0-23 [33] cellranger_1.1.0 nlme_3.1-131 psych_1.7.8 rvest_0.3.2 gtools_3.5.0 devtools_1.12.0 XML_3.98-1.9 zoo_1.7-14
[41] scales_0.5.0 hms_0.3 RBGL_1.50.0 dummies_1.5.6 memoise_1.1.0 gridExtra_2.3 MuMIn_1.15.6 KMsurv_0.1-5
[49] stringi_1.1.6 RSQLite_2.0 rmeta_2.16 S4Vectors_0.12.2 lava_1.5 rlang_0.1.2 pkgconfig_2.0.1 bitops_1.0-6
[57] pracma_2.0.7 lattice_0.20-35 bindr_0.1 labeling_0.3 cmprsk_2.2-7 survivalROC_1.0.3 CVST_0.2-1 cowplot_0.8.0
[65] bit_1.1-12 tidyselect_0.2.0 plyr_1.8.4 IRanges_2.8.2 nnls_1.4 bootstrap_2017.2 DBI_0.7 haven_1.1.0
[73] foreign_0.8-69 withr_2.0.0 nnet_7.3-12 abind_1.4-5 RCurl_1.95-4.8 modelr_0.1.1 precrec_0.7.1 survMisc_0.5.4
[81] KernSmooth_2.23-15 ellipse_0.3-8 timereg_1.9.0 readxl_1.0.0 Rgraphviz_2.18.0 blob_1.1.0 forcats_0.2.0 digest_0.6.12
[89] xtable_1.8-2 numDeriv_2016.8-1 pec_2.5.4 stats4_3.3.2 munsell_0.4.3 quadprog_1.5-5

# please paste here the result of
devtools::session_info()
kassambara commented 6 years ago

This error is not reproducible on my computer with the latest version of survminer.

Session Infos:

Session info ----------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, darwin13.4.0        
 ui       RStudio (1.1.423)           
 language (EN)                        
 collate  fr_FR.UTF-8                 
 tz       Europe/Paris                
 date     2018-06-28                  

Packages --------------------------------------------------------------------------------------
 package    * version    date       source                               
 assertthat   0.2.0.9000 2017-11-08 Github (hadley/assertthat@37f0a56)   
 backports    1.1.2      2017-12-13 cran (@1.1.2)                        
 base       * 3.3.2      2016-10-31 local                                
 bindr        0.1        2016-11-13 cran (@0.1)                          
 bindrcpp     0.2        2017-06-17 cran (@0.2)                          
 bookdown     0.7        2018-02-18 CRAN (R 3.3.2)                       
 broom        0.4.3      2017-11-20 cran (@0.4.3)                        
 cmprsk       2.2-7      2014-06-17 CRAN (R 3.3.0)                       
 colorspace   1.4-0      2017-10-23 url                                  
 data.table   1.10.4     2017-02-01 cran (@1.10.4)                       
 datasets   * 3.3.2      2016-10-31 local                                
 devtools   * 1.13.1     2017-05-13 CRAN (R 3.3.2)                       
 digest       0.6.15     2018-01-28 cran (@0.6.15)                       
 dplyr        0.7.4      2017-09-28 cran (@0.7.4)                        
 evaluate     0.10.1     2017-06-24 cran (@0.10.1)                       
 foreign      0.8-67     2016-09-13 CRAN (R 3.3.2)                       
 ggplot2    * 2.2.1.9000 2018-06-17 Github (tidyverse/ggplot2@ff41bc8)   
 ggpubr     * 0.1.6.999  2018-06-17 Github (kassambara/ggpubr@84baca2)   
 glue         1.2.0      2017-10-29 cran (@1.2.0)                        
 graphics   * 3.3.2      2016-10-31 local                                
 grDevices  * 3.3.2      2016-10-31 local                                
 grid         3.3.2      2016-10-31 local                                
 gridExtra    2.3        2017-09-09 cran (@2.3)                          
 gtable       0.2.0      2016-02-26 CRAN (R 3.3.0)                       
 htmltools    0.3.6      2017-04-28 cran (@0.3.6)                        
 km.ci        0.5-2      2009-08-30 CRAN (R 3.3.0)                       
 KMsurv       0.1-5      2012-12-03 CRAN (R 3.3.0)                       
 knitr        1.18       2017-12-27 cran (@1.18)                         
 labeling     0.3        2014-08-23 CRAN (R 3.3.0)                       
 lattice      0.20-34    2016-09-06 CRAN (R 3.3.2)                       
 lazyeval     0.2.1      2017-10-29 cran (@0.2.1)                        
 magrittr   * 1.5        2014-11-22 CRAN (R 3.3.0)                       
 Matrix       1.2-11     2017-08-16 CRAN (R 3.3.2)                       
 memoise      1.1.0      2017-04-21 cran (@1.1.0)                        
 methods    * 3.3.2      2016-10-31 local                                
 mnormt       1.5-5      2016-10-15 CRAN (R 3.3.0)                       
 munsell      0.4.3      2016-02-13 CRAN (R 3.3.0)                       
 nlme         3.1-131    2017-02-06 CRAN (R 3.3.2)                       
 parallel     3.3.2      2016-10-31 local                                
 pkgconfig    2.0.1      2017-03-21 cran (@2.0.1)                        
 plyr         1.8.4      2016-06-08 CRAN (R 3.3.0)                       
 psych        1.7.3.21   2017-03-22 cran (@1.7.3.2)                      
 purrr        0.2.4      2017-10-18 cran (@0.2.4)                        
 R6           2.2.2      2017-06-17 cran (@2.2.2)                        
 Rcpp         0.12.14    2017-11-23 cran (@0.12.14)                      
 reshape2     1.4.3      2017-12-11 cran (@1.4.3)                        
 rlang        0.2.0.9001 2018-06-17 Github (tidyverse/rlang@ba4fb06)     
 rmarkdown    1.9.3      2018-03-10 Github (rstudio/rmarkdown@e67c789)   
 rprojroot    1.3-2      2018-01-03 cran (@1.3-2)                        
 scales       0.5.0.9000 2018-06-17 Github (hadley/scales@4056ec3)       
 splines      3.3.2      2016-10-31 local                                
 stats      * 3.3.2      2016-10-31 local                                
 stringi      1.1.6      2017-11-17 cran (@1.1.6)                        
 stringr      1.3.0      2018-02-19 cran (@1.3.0)                        
 survival   * 2.41-3     2017-04-04 CRAN (R 3.3.2)                       
 survminer  * 0.3.1.999  2017-06-05 Github (kassambara/survminer@8511dee)
 survMisc     0.5.4      2016-11-23 CRAN (R 3.3.2)                       
 tibble       1.3.4      2017-08-22 cran (@1.3.4)                        
 tidyr        0.8.1.9000 2018-06-17 Github (tidyverse/tidyr@cbdd14e)     
 tools        3.3.2      2016-10-31 local                                
 utils      * 3.3.2      2016-10-31 local                                
 withr        2.1.2      2018-06-17 Github (jimhester/withr@dbcd7cd)     
 xfun         0.1        2018-01-22 CRAN (R 3.3.2)                       
 xtable       1.8-2      2016-02-05 CRAN (R 3.3.0)                       
 yaml         2.1.16     2017-12-12 cran (@2.1.16)                       
 zoo          1.7-14     2016-12-16 CRAN (R 3.3.2)                       
rbrecheisen commented 5 years ago

Hi,

Perhaps you might reopen this issue. I get the same error and I just installed survminer so it should be the latest version.

require("survival")
fit2 <- survfit( Surv(time, status) ~ sex + rx + adhere, data = colon)
ggsurv <- ggsurvplot(fit2, fun = "event", conf.int = TRUE)
ggsurv$plot + theme_bw() + facet_grid(rx ~ adhere)

Output:

 Error in f(...) : Aesthetics can not vary with a ribbon

sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.6

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] survminer_0.4.3 ggpubr_0.2 magrittr_1.5 ggplot2_3.1.0 survival_2.43-3

loaded via a namespace (and not attached): [1] Rcpp_0.12.19 pillar_1.3.0 compiler_3.5.1 plyr_1.8.4 bindr_0.1.1
[6] tools_3.5.1 digest_0.6.18 tibble_1.4.2 gtable_0.2.0 nlme_3.1-137
[11] lattice_0.20-35 pkgconfig_2.0.2 rlang_0.3.0.1 Matrix_1.2-14 rstudioapi_0.8
[16] cmprsk_2.2-7 yaml_2.2.0 xfun_0.4 bindrcpp_0.2.2 gridExtra_2.3
[21] stringr_1.3.1 knitr_1.21 withr_2.1.2 dplyr_0.7.8 generics_0.0.2
[26] survMisc_0.5.5 grid_3.5.1 tidyselect_0.2.5 data.table_1.12.0 glue_1.3.0
[31] R6_2.3.0 KMsurv_0.1-5 km.ci_0.5-2 reshape2_1.4.3 purrr_0.2.5
[36] tidyr_0.8.2 scales_1.0.0 backports_1.1.3 splines_3.5.1 assertthat_0.2.0 [41] xtable_1.8-3 colorspace_1.3-2 labeling_0.3 stringi_1.2.4 lazyeval_0.2.1
[46] munsell_0.5.0 broom_0.5.1 crayon_1.3.4 zoo_1.8-4

aubertjc commented 5 years ago

Hi,

Don’t write :

conf.int = TRUE

and it should be ok

Le 27 janv. 2019 à 09:11, Ralph Brecheisen notifications@github.com a écrit :

Hi,

Perhaps you might reopen this issue. I get the same error and I just installed survminer so it should be the latest version.

require("survival") fit2 <- survfit( Surv(time, status) ~ sex + rx + adhere, data = colon) ggsurv <- ggsurvplot(fit2, fun = "event", conf.int = TRUE) ggsurv$plot + theme_bw() + facet_grid(rx ~ adhere) Output:

Error in f(...) : Aesthetics can not vary with a ribbon sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.6

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] survminer_0.4.3 ggpubr_0.2 magrittr_1.5 ggplot2_3.1.0 survival_2.43-3

loaded via a namespace (and not attached): [1] Rcpp_0.12.19 pillar_1.3.0 compiler_3.5.1 plyr_1.8.4 bindr_0.1.1 [6] tools_3.5.1 digest_0.6.18 tibble_1.4.2 gtable_0.2.0 nlme_3.1-137 [11] lattice_0.20-35 pkgconfig_2.0.2 rlang_0.3.0.1 Matrix_1.2-14 rstudioapi_0.8 [16] cmprsk_2.2-7 yaml_2.2.0 xfun_0.4 bindrcpp_0.2.2 gridExtra_2.3 [21] stringr_1.3.1 knitr_1.21 withr_2.1.2 dplyr_0.7.8 generics_0.0.2 [26] survMisc_0.5.5 grid_3.5.1 tidyselect_0.2.5 data.table_1.12.0 glue_1.3.0 [31] R6_2.3.0 KMsurv_0.1-5 km.ci_0.5-2 reshape2_1.4.3 purrr_0.2.5 [36] tidyr_0.8.2 scales_1.0.0 backports_1.1.3 splines_3.5.1 assertthat_0.2.0 [41] xtable_1.8-3 colorspace_1.3-2 labeling_0.3 stringi_1.2.4 lazyeval_0.2.1 [46] munsell_0.5.0 broom_0.5.1 crayon_1.3.4 zoo_1.8-4

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kassambara/survminer/issues/315#issuecomment-457898215, or mute the thread https://github.com/notifications/unsubscribe-auth/AOP4ctCZ2GPhOEbX7sRrfXoCUczJV_uVks5vHV9HgaJpZM4UuSY0.

jean-christophe aubert aubertjc@mac.com mailto:aubertjc@mac.com

rbrecheisen commented 5 years ago

Thank, that seems to take care of the error indeed. Of course, it would be nice to have actually have those CIs. I hope a fix can be pushed soon.

joeyjoeyjojo commented 5 years ago

I am having the same issue.

removing conf.int=TRUE allows the code to run, but then there are no confidence intervals in the output.

mcuendet commented 5 years ago

Hi,

I have the same issue and I need these CIs !!

Please let me know if anyone found a fix!

Best, Michel

Minimal code to reproduce :

df <-lung
fit <- survfit("Surv(time, status == 2) ~ ph.ecog", data=df)

p<- ggsurvplot(fit,
               data = df, 
               conf.int = T 
)             
print(p)       

Error in f(...) : Aesthetics can not vary with a ribbon

HUSAIN23 commented 4 years ago

i tried to run TCGAbiolinks GUI ,i downloaded data drom menu GET GDC data and i select file from directory to analyze clinical analysis adn clicked on generate survival plot but it shows that Aesthetics can not vary with a ribbon

kassambara commented 4 years ago

fixed now, see #443