wilkelab / cowplot

cowplot: Streamlined Plot Theme and Plot Annotations for ggplot2
https://wilkelab.org/cowplot/
701 stars 84 forks source link

warning message: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0. #190

Closed Yunuuuu closed 1 year ago

Yunuuuu commented 1 year ago

When I used scater::plotColData, there always prompts some annoying message by ggplot2 deprecated arguments size from element_text() and element_rect()

     invisible(lapply(c("sum", "detected", "subse
     ts_Mito_percent"), function(y) {
         res <- scater::plotColData(sce_raw,
             x = "Sample", y = y,
             colour_by = switch(y,
                 sum = "low_lib_size",
                 detected = "low_n_features",
                 subsets_Mito_percent = "high_sub
     sets_Mito_percent"
             ),
             other_fields = "sample_type"
         )
         if (y %in% c("sum", "detected")) res <- 
     res + scale_y_log10()
         qc_plot <- res +
             facet_grid(
                 cols = vars(sample_type),
                 scales = "free_x", space = "free
     _x"
             ) +
             ggtitle(y) + labs(x = NULL, y = NULL
     ) +
             theme(axis.text.x = element_text(ang
     le = 60, hjust = 1))
         ggsave(
             here("figures", "qc", paste0("raw_",
      y, "_qc.pdf")),
             qc_plot,
             device = pdf, width = 12, height = 5

         )
     }))

here is the output:

Warning messages:
1: In y_by_out$val : partial match of 'val' to 'value'
2: In x_by_out$val : partial match of 'val' to 'value'
3: The `size` argument of `element_line()` is
deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the
  cowplot package.
  Please report the issue at
  <https://github.com/wilkelab/cowplot/issues>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to
see where this warning was generated. 
4: The `size` argument of `element_rect()` is
deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the
  cowplot package.
  Please report the issue at
  <https://github.com/wilkelab/cowplot/issues>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to
see where this warning was generated. 

My sessionInfo is here:

R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_rt.so

locale:
 [1] LC_CTYPE=en_US.UTF-8      
 [2] LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=zh_CN.UTF-8      
 [8] LC_NAME=C                 
 [9] LC_ADDRESS=C              
[10] LC_TELEPHONE=C            
[11] LC_MEASUREMENT=zh_CN.UTF-8
[12] LC_IDENTIFICATION=C       

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

other attached packages:
 [1] here_1.0.1                 
 [2] magrittr_2.0.3             
 [3] ggplot2_3.3.6.9000         
 [4] SingleCellExperiment_1.20.0
 [5] SummarizedExperiment_1.28.0
 [6] Biobase_2.58.0             
 [7] GenomicRanges_1.50.0       
 [8] GenomeInfoDb_1.34.0        
 [9] IRanges_2.32.0             
[10] S4Vectors_0.36.0           
[11] BiocGenerics_0.44.0        
[12] MatrixGenerics_1.10.0      
[13] matrixStats_0.62.0         

loaded via a namespace (and not attached):
 [1] ggrepel_0.9.1            
 [2] Rcpp_1.0.9               
 [3] rsvd_1.0.5               
 [4] lattice_0.20-45          
 [5] pak_0.3.1                
 [6] assertthat_0.2.1         
 [7] rprojroot_2.0.3          
 [8] digest_0.6.30            
 [9] utf8_1.2.2               
[10] R6_2.5.1                 
[11] pillar_1.8.1             
[12] sparseMatrixStats_1.10.0 
[13] zlibbioc_1.44.0          
[14] rlang_1.0.6              
[15] irlba_2.3.5.1            
[16] Matrix_1.5-1             
[17] labeling_0.4.2           
[18] BiocNeighbors_1.16.0     
[19] BiocParallel_1.32.0      
[20] RCurl_1.98-1.9           
[21] munsell_0.5.0            
[22] beachmat_2.14.0          
[23] DelayedArray_0.24.0      
[24] compiler_4.2.1           
[25] vipor_0.4.5              
[26] BiocSingular_1.14.0      
[27] pkgconfig_2.0.3          
[28] ggbeeswarm_0.6.0         
[29] tidyselect_1.2.0         
[30] tibble_3.1.8             
[31] gridExtra_2.3            
[32] GenomeInfoDbData_1.2.9   
[33] progressr_0.11.0         
[34] codetools_0.2-18         
[35] viridisLite_0.4.1        
[36] fansi_1.0.3              
[37] crayon_1.5.2             
[38] dplyr_1.0.10             
[39] withr_2.5.0              
[40] bitops_1.0-7             
[41] grid_4.2.1               
[42] jsonlite_1.8.3           
[43] gtable_0.3.1             
[44] lifecycle_1.0.3.9000     
[45] DBI_1.1.3                
[46] scales_1.2.1             
[47] ScaledMatrix_1.6.0       
[48] cli_3.4.1                
[49] scuttle_1.8.0            
[50] farver_2.1.1             
[51] XVector_0.38.0           
[52] viridis_0.6.2            
[53] scater_1.26.0            
[54] DelayedMatrixStats_1.20.0
[55] generics_0.1.3           
[56] vctrs_0.5.0              
[57] cowplot_1.1.1            
[58] ggsci_2.9                
[59] tools_4.2.1              
[60] glue_1.6.2               
[61] beeswarm_0.4.0           
[62] parallel_4.2.1           
[63] colorspace_2.0-3  
clauswilke commented 1 year ago

Thanks for bringing this up. This is caused by a change in the latest released ggplot2. A couple of things to consider for a fix:

Also, a general comment: When reporting issues, it's most productive to try to come up with a minimal example that causes the problem. Minimal examples should definitely not depend on other packages or have all sorts of irrelevant, distracting code. Here, I believe the problem is caused by using certain cowplot themes, but I can't tell from the provided example.

clauswilke commented 1 year ago

I see you provided a minimal example here: https://github.com/wilkelab/cowplot/pull/189#issuecomment-1305723678

Yunuuuu commented 1 year ago

Oh, I'll put it here

Yunuuuu commented 1 year ago

A minimal example

library(ggplot2)
library(cowplot)

ggplot(mtcars) +
    geom_point(aes(mpg, drat)) +
    theme_cowplot()

Warning messages:
1: The `size` argument of `element_line()` is
deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the
  cowplot package.
  Please report the issue at
  <https://github.com/wilkelab/cowplot/issues>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to
see where this warning was generated. 
2: The `size` argument of `element_rect()` is
deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
ℹ The deprecated feature was likely used in the
  cowplot package.
  Please report the issue at
  <https://github.com/wilkelab/cowplot/issues>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to
see where this warning was generated. 
Yunuuuu commented 1 year ago

fixed by https://github.com/wilkelab/cowplot/pull/189