Adjusting font size with theme() does not work with figure_plot = TRUE
Opened this issue · 1 comments
Hi @samuel-marsh, thank you for the excellent package !! I really enjoy the enhanced plots.
I am trying to adjust the font size of a DimPlot_scCustom() using theme(). It works as expected when figure_plot = FALSE but does not work properly when figure_plot = TRUE. I fear the same issue is happening with any plot that allows figure_plot = TRUE.
Here is a reproducible example:
require(Seurat)
require(scCustomize)
require(ggplot2)
A <- DimPlot_scCustom(seurat_object = pbmc_small,
figure_plot = TRUE)
B <- DimPlot_scCustom(seurat_object = pbmc_small,
figure_plot = F) +
theme(
axis.title = element_text(size = 40),
axis.text = element_text(size = 40),
legend.text = element_text(size = 40),
plot.title = element_blank())
C <- DimPlot_scCustom(seurat_object = pbmc_small,
figure_plot = TRUE)+
theme(
axis.title = element_text(size = 40),
axis.text = element_text(size = 40),
legend.text = element_text(size = 40),
plot.title = element_blank())
A | B | C
Which produces the image below.
A similar issue happens when I try to replace other aspects of the plot with theme(). For example,
DimPlot_scCustom(seurat_object = pbmc_small,
figure_plot = TRUE) + DarkTheme()
Will produce the plot below:
Is there a way to control the aspects of the plot when using figure_plot = TRUE?
sessionInfo() output
R Under development (unstable) (2023-03-29 r84123)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 14.5
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.5.1 scCustomize_2.1.2 Seurat_5.1.0 SeuratObject_5.0.2
[5] sp_2.1-4
loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 rstudioapi_0.16.0 jsonlite_1.8.8
[4] shape_1.4.6.1 magrittr_2.0.3 spatstat.utils_3.0-5
[7] ggbeeswarm_0.7.2 farver_2.1.2 GlobalOptions_0.1.2
[10] vctrs_0.6.5 ROCR_1.0-11 spatstat.explore_3.3-1
[13] paletteer_1.6.0 janitor_2.2.0 htmltools_0.5.8.1
[16] forcats_1.0.0 sctransform_0.4.1 parallelly_1.37.1
[19] KernSmooth_2.23-24 htmlwidgets_1.6.4 ica_1.0-3
[22] plyr_1.8.9 plotly_4.10.4 zoo_1.8-12
[25] lubridate_1.9.3 igraph_2.0.3 mime_0.12
[28] lifecycle_1.0.4 pkgconfig_2.0.3 Matrix_1.6-4
[31] R6_2.5.1 fastmap_1.2.0 fitdistrplus_1.2-1
[34] future_1.33.2 shiny_1.9.1 snakecase_0.11.1
[37] digest_0.6.36 colorspace_2.1-1 rematch2_2.1.2
[40] patchwork_1.2.0 tensor_1.5 prismatic_1.1.2
[43] RSpectra_0.16-2 irlba_2.3.5.1 labeling_0.4.3
[46] progressr_0.14.0 fansi_1.0.6 spatstat.sparse_3.1-0
[49] timechange_0.3.0 httr_1.4.7 polyclip_1.10-7
[52] abind_1.4-5 compiler_4.4.0 withr_3.0.1
[55] fastDummies_1.7.3 MASS_7.3-61 tools_4.4.0
[58] vipor_0.4.7 lmtest_0.9-40 beeswarm_0.4.0
[61] httpuv_1.6.15 future.apply_1.11.2 goftest_1.2-3
[64] glue_1.7.0 nlme_3.1-165 promises_1.3.0
[67] grid_4.4.0 Rtsne_0.17 cluster_2.1.6
[70] reshape2_1.4.4 generics_0.1.3 gtable_0.3.5
[73] spatstat.data_3.1-2 tidyr_1.3.1 data.table_1.15.4
[76] utf8_1.2.4 spatstat.geom_3.3-2 RcppAnnoy_0.0.22
[79] ggrepel_0.9.5 RANN_2.6.1 pillar_1.9.0
[82] stringr_1.5.1 spam_2.10-0 RcppHNSW_0.6.0
[85] ggprism_1.0.5 later_1.3.2 circlize_0.4.16
[88] splines_4.4.0 dplyr_1.1.4 lattice_0.22-6
[91] survival_3.7-0 deldir_2.0-4 tidyselect_1.2.1
[94] miniUI_0.1.1.1 pbapply_1.7-2 gridExtra_2.3
[97] scattermore_1.2 matrixStats_1.3.0 stringi_1.8.4
[100] lazyeval_0.2.2 codetools_0.2-20 tibble_3.2.1
[103] cli_3.6.3 uwot_0.2.2 xtable_1.8-4
[106] reticulate_1.38.0 munsell_0.5.1 Rcpp_1.0.12
[109] globals_0.16.3 spatstat.random_3.3-1 png_0.1-8
[112] ggrastr_1.0.2 spatstat.univar_3.0-0 parallel_4.4.0
[115] dotCall64_1.1-1 listenv_0.9.1 viridisLite_0.4.2
[118] scales_1.3.0 ggridges_0.5.6 leiden_0.4.3.1
[121] purrr_1.0.2 rlang_1.1.4 cowplot_1.1.3
Thank you!
Wendell
Hi Wendell,
Sorry for the delay getting back to you. Thanks for bringing up the issue. The reason this is happening is because the UMAP axes added by figure_plot
are actually a second ggplot2 object and then it is patchwork’ed together. If you use patchwork &
instead of ggplot2 +
does that resolve the issue?
Best,
Sam