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

ggforest visual glitch when using many variables #241

Closed
mmoisse opened this issue Jul 4, 2017 · 7 comments
Closed

ggforest visual glitch when using many variables #241

mmoisse opened this issue Jul 4, 2017 · 7 comments

Comments

@mmoisse
Copy link

mmoisse commented Jul 4, 2017

Expected behavior

A nice banded forest plot
p

Actual behavior

A shift occurs in the bands and text of the forest plot
q

Steps to reproduce the problem

library(survival)
library(survminer)
fit2 <- coxph( Surv(stop, event) ~ size + rx, data = bladder )
ggforest(fit2)
## Add extra variables
for(i in 1:10) { var=paste0("pc",i); bladder[,var] <- runif(nrow(bladder)) }
fit2 <- coxph( Surv(stop, event) ~ size + rx + pc1 + pc2 + pc3 + pc4 + pc5 + pc6 + pc7 + pc8 + pc9 + pc10, data = bladder )
ggforest(fit2)

session_info()

Session info --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, linux-gnu           
 ui       X11                         
 language en_UK.uft-8                 
 collate  en_IE.UTF-8                 
 tz       Europe/Brussels             
 date     2017-07-04                  

Packages ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 package    * version   date       source                               
 assertthat   0.2.0     2017-04-11 CRAN (R 3.3.2)                       
 bindr        0.1       2016-11-13 cran (@0.1)                          
 bindrcpp     0.2       2017-06-17 cran (@0.2)                          
 broom        0.4.2     2017-02-13 CRAN (R 3.3.2)                       
 cmprsk       2.2-7     2014-06-17 CRAN (R 3.3.2)                       
 colorout   * 1.1-2     2016-04-11 Github (jalvesaq/colorout@6538970)   
 colorspace   1.3-2     2016-12-14 CRAN (R 3.3.2)                       
 data.table   1.10.4    2017-02-01 CRAN (R 3.3.2)                       
 devtools     1.12.0    2016-12-05 CRAN (R 3.3.2)                       
 digest       0.6.12    2017-01-27 CRAN (R 3.3.2)                       
 dplyr        0.7.1     2017-06-22 cran (@0.7.1)                        
 foreign      0.8-68    2017-04-24 CRAN (R 3.3.2)                       
 ggplot2    * 2.2.1     2016-12-30 CRAN (R 3.3.2)                       
 ggpubr     * 0.1.4     2017-06-28 CRAN (R 3.3.2)                       
 glue         1.1.1     2017-06-21 cran (@1.1.1)                        
 gridExtra    2.2.1     2016-02-29 CRAN (R 3.3.2)                       
 gtable       0.2.0     2016-02-26 CRAN (R 3.3.2)                       
 km.ci        0.5-2     2009-08-30 CRAN (R 3.3.2)                       
 KMsurv       0.1-5     2012-12-03 CRAN (R 3.3.2)                       
 knitr        1.15.1    2016-11-22 CRAN (R 3.3.2)                       
 labeling     0.3       2014-08-23 CRAN (R 3.3.2)                       
 lattice      0.20-35   2017-03-25 CRAN (R 3.3.2)                       
 lazyeval     0.2.0     2016-06-12 CRAN (R 3.3.2)                       
 magrittr   * 1.5       2014-11-22 CRAN (R 3.3.2)                       
 Matrix       1.2-10    2017-04-28 CRAN (R 3.3.2)                       
 memoise      1.1.0     2017-04-21 CRAN (R 3.3.2)                       
 mnormt       1.5-5     2016-10-15 CRAN (R 3.3.2)
 munsell      0.4.3     2016-02-13 CRAN (R 3.3.2)
 nlme         3.1-131   2017-02-06 CRAN (R 3.3.2)
 nvimcom    * 0.9-25    2017-02-21 local
 pkgconfig    2.0.1     2017-03-21 cran (@2.0.1)
 plyr         1.8.4     2016-06-08 CRAN (R 3.3.2)
 psych        1.7.5     2017-05-03 CRAN (R 3.3.2)
 purrr        0.2.2.2   2017-05-11 CRAN (R 3.3.2)
 R6           2.2.2     2017-06-17 cran (@2.2.2)
 Rcpp         0.12.11   2017-05-22 cran (@0.12.11)
 reshape2     1.4.2     2016-10-22 CRAN (R 3.3.2)
 rlang        0.1.1     2017-05-18 cran (@0.1.1)
 scales       0.4.1     2016-11-09 CRAN (R 3.3.2)
 setwidth   * 1.0-4     2015-07-07 CRAN (R 3.3.0)
 stringi      1.1.5     2017-04-07 CRAN (R 3.3.2)
 stringr      1.2.0     2017-02-18 CRAN (R 3.3.2)
 survival   * 2.41-3    2017-04-04 CRAN (R 3.3.2)
 survminer  * 0.4.0.999 2017-07-04 Github (kassambara/survminer@bea688c)
 survMisc     0.5.4     2016-11-23 CRAN (R 3.3.2)
 tibble       1.3.3     2017-05-28 cran (@1.3.3)
 tidyr        0.6.3     2017-05-15 cran (@0.6.3)
 withr        1.0.2     2016-06-20 CRAN (R 3.3.2)
 xtable       1.8-2     2016-02-05 cran (@1.8-2)
 zoo          1.8-0     2017-04-12 CRAN (R 3.3.2)
mmoisse added a commit to mmoisse/survminer that referenced this issue Jul 4, 2017
Changed the 0.91 factor in grid.text to 0.87 to match grid.rect
@fabian-s
Copy link
Contributor

fabian-s commented Oct 30, 2017

I'm having the same problem - the table on the left and the plotted CIs don't align for models with more than 3 variables.

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] bindrcpp_0.2    survminer_0.4.0 ggpubr_0.1.5    pander_0.6.1    desctable_0.1.0
 [6] ggfortify_0.4.1 survival_2.41-3 rlang_0.1.2     broom_0.4.2     forcats_0.2.0  
[11] dplyr_0.7.4     purrr_0.2.4     readr_1.1.1     tidyr_0.7.2     tibble_1.3.4   
[16] ggplot2_2.2.1   tidyverse_1.1.1 lubridate_1.6.0 readxl_1.0.0    magrittr_1.5   
[21] knitr_1.17     

loaded via a namespace (and not attached):
 [1] zoo_1.8-0         reshape2_1.4.2    splines_3.4.1     haven_1.1.0       lattice_0.20-35  
 [6] colorspace_1.3-2  yaml_2.1.14       survMisc_0.5.4    foreign_0.8-69    glue_1.1.1       
[11] modelr_0.1.1      bindr_0.1         plyr_1.8.4        stringr_1.2.0     munsell_0.4.3    
[16] gtable_0.2.0      cellranger_1.1.0  rvest_0.3.2       psych_1.7.8       labeling_0.3     
[21] parallel_3.4.1    Rcpp_0.12.13      xtable_1.8-2      scales_0.5.0      cmprsk_2.2-7     
[26] jsonlite_1.5      km.ci_0.5-2       gridExtra_2.3     mnormt_1.5-5      hms_0.3          
[31] digest_0.6.12     stringi_1.1.5     KMsurv_0.1-5      grid_3.4.1        tools_3.4.1      
[36] lazyeval_0.2.0    pkgconfig_2.0.1   Matrix_1.2-11     data.table_1.10.4 xml2_1.1.1       
[41] assertthat_0.2.0  httr_1.3.1        R6_2.2.2          nlme_3.1-131      compiler_3.4.1 

Too bad, this could be a terrific function! Thanks for the package, everything else works great

@JulianCollins
Copy link

JulianCollins commented Nov 13, 2017

Having the same issue. More space for longer title ('main') would also be great - not sure if the vertical misalignment of the top row is connected to that.
r20_70

R20_Surv_5_cox <- coxph(Surv(Time, Status) ~ AGE + ETHNICITY + GENDER_NAME + A1C_FIRSTGRP, data = R20_Surv_1)

ggforest(R20_Surv_5_cox)

sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] metafor_2.0-0 Matrix_1.2-11 survival_2.41-3 lubridate_1.7.1 survminer_0.4.0 ggpubr_0.1.5 magrittr_1.5 forcats_0.2.0
[9] stringr_1.2.0 dplyr_0.7.4 purrr_0.2.4 readr_1.1.1 tidyr_0.7.2 tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.2.0

loaded via a namespace (and not attached):
[1] tidyselect_0.2.3 zoo_1.8-0 reshape2_1.4.2 splines_3.4.2 haven_1.1.0 lattice_0.20-35 colorspace_1.3-2
[8] yaml_2.1.14 survMisc_0.5.4 rlang_0.1.4 foreign_0.8-69 glue_1.2.0 modelr_0.1.1 readxl_1.0.0
[15] bindrcpp_0.2 bindr_0.1 plyr_1.8.4 munsell_0.4.3 gtable_0.2.0 cellranger_1.1.0 rvest_0.3.2
[22] psych_1.7.8 labeling_0.3 knitr_1.17 parallel_3.4.2 broom_0.4.2 Rcpp_0.12.13 xtable_1.8-2
[29] scales_0.5.0 cmprsk_2.2-7 jsonlite_1.5 km.ci_0.5-2 gridExtra_2.3 mnormt_1.5-5 digest_0.6.12
[36] hms_0.3 packrat_0.4.8-1 stringi_1.1.5 KMsurv_0.1-5 grid_3.4.2 cli_1.0.0 tools_3.4.2
[43] lazyeval_0.2.1 crayon_1.3.4 pkgconfig_2.0.1 data.table_1.10.4-3 xml2_1.1.1 assertthat_0.2.0 httr_1.3.1
[50] rstudioapi_0.7 R6_2.2.2 nlme_3.1-131 compiler_3.4.2

@fabian-s
Copy link
Contributor

@pbiecek Please check out my pull request, I think I fixed the problem.

@pbiecek
Copy link
Contributor

pbiecek commented Nov 15, 2017

Thanks, great fix!
@kassambara would you merge this pull request?

@kassambara
Copy link
Owner

Merged know, thanks!

@fabian-s
Copy link
Contributor

Cool, thank you guys for the great package!

kassambara added a commit that referenced this issue Nov 15, 2017
@JulianCollins
Copy link

This works great now - thanks very much for speedy response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants