Skip to content

BUG: DimPlot label.box color fill broken with ggplot2 4.0.0 #10156

@samuel-marsh

Description

@samuel-marsh

Issue Description

Hi Seurat Team (tagging @anashen @YoukaiFromAccounting here),

Following the merge of #10028 the label.box parameter in DimPlot (passed to LabelClusters no longer properly colors the filled boxes. Given the changes made spatial plotting there I wanted to leave this one to Seurat team for how you would like to handle fix. Issue comes in that the scale_fill_manual line was removed from LabelClusters if box = TRUE. This is because the color column in the "labels.loc" data.frame no longer contains valid color values.

Image

Hence just restoring that line then spits the following error:

Error in `geom.use()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 2nd layer.
Caused by error:
! Unknown colour name: -5.69291337379421

Again just wanted to leave this one with you all to figure out how to handle with the updates/changes to spatial plotting.

Thanks!
Best,
Sam

Reproducing Code Example

library(Seurat)
DimPlot(pbmc_small, label.box = T, pt.size = 0.25, label.size = 5, label = T, cols = DiscretePalette(n = 3, palette = "polychrome"))

Error Message

Additional Comments

No response

Session Info

> sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.6.1

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.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

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] cowplot_1.2.0          rliger_2.2.1           beepr_2.0              reticulate_1.43.0      qs2_0.1.5              patchwork_1.3.2        scCustomize_3.2.1.0019 SeuratWrappers_0.4.0  
 [9] Seurat_5.3.1.9999      SeuratObject_5.1.0     sp_2.2-0               lubridate_1.9.4        forcats_1.0.1          stringr_1.5.2          dplyr_1.1.4            purrr_1.1.0           
[17] readr_2.1.5            tidyr_1.3.1            tibble_3.3.0           ggplot2_4.0.0          tidyverse_2.0.0        rlang_1.1.6           

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22       splines_4.5.0          later_1.4.4            prismatic_1.1.2        R.oo_1.27.1            polyclip_1.10-7        janitor_2.2.1          fastDummies_1.7.5     
  [9] lifecycle_1.0.4        globals_0.18.0         processx_3.8.6         lattice_0.22-7         MASS_7.3-65            magrittr_2.0.4         plotly_4.11.0          remotes_2.5.0         
 [17] httpuv_1.6.16          sctransform_0.4.2      spam_2.11-1            sessioninfo_1.2.3      pkgbuild_1.4.8         spatstat.sparse_3.1-0  pbapply_1.7-4          RColorBrewer_1.1-3    
 [25] abind_1.4-8            pkgload_1.4.1          audio_0.1-11           Rtsne_0.17             R.utils_2.13.0         BiocGenerics_0.54.0    circlize_0.4.16        IRanges_2.42.0        
 [33] S4Vectors_0.46.0       ggrepel_0.9.6          irlba_2.3.5.1          listenv_0.9.1          spatstat.utils_3.2-0   goftest_1.2-3          RSpectra_0.16-2        spatstat.random_3.4-2 
 [41] fitdistrplus_1.2-4     parallelly_1.45.1      DelayedArray_0.34.1    codetools_0.2-20       RApiSerialize_0.1.4    tidyselect_1.2.1       shape_1.4.6.1          farver_2.1.2          
 [49] stats4_4.5.0           matrixStats_1.5.0      spatstat.explore_3.5-3 jsonlite_2.0.0         ellipsis_0.3.2         progressr_0.15.1       ggridges_0.5.7         survival_3.8-3        
 [57] tools_4.5.0            ica_1.0-3              Rcpp_1.1.0             glue_1.8.0             SparseArray_1.8.0      gridExtra_2.3          MatrixGenerics_1.20.0  usethis_3.2.1         
 [65] HDF5Array_1.36.0       withr_3.0.2            BiocManager_1.30.26    fastmap_1.2.0          rhdf5filters_1.20.0    callr_3.7.6            digest_0.6.37          rsvd_1.0.5            
 [73] timechange_0.3.0       R6_2.6.1               mime_0.13              ggprism_1.0.7          colorspace_2.1-2       scattermore_1.2        tensor_1.5.1           dichromat_2.0-0.1     
 [81] spatstat.data_3.1-8    h5mread_1.0.1          R.methodsS3_1.8.2      generics_0.1.4         data.table_1.17.8      S4Arrays_1.8.0         httr_1.4.7             htmlwidgets_1.6.4     
 [89] uwot_0.2.3             pkgconfig_2.0.3        gtable_0.3.6           lmtest_0.9-40          S7_0.2.0               XVector_0.48.0         htmltools_0.5.8.1      dotCall64_1.2         
 [97] scales_1.4.0           png_0.1-8              spatstat.univar_3.1-4  snakecase_0.11.1       rstudioapi_0.17.1      tzdb_0.5.0             reshape2_1.4.4         nlme_3.1-168          
[105] curl_7.0.0             rhdf5_2.52.0           cachem_1.1.0           zoo_1.8-14             GlobalOptions_0.1.2    KernSmooth_2.23-26     parallel_4.5.0         miniUI_0.1.2          
[113] vipor_0.4.7            ggrastr_1.0.2          desc_1.4.3             pillar_1.11.1          grid_4.5.0             vctrs_0.6.5            RANN_2.6.2             promises_1.3.3        
[121] stringfish_0.17.0      xtable_1.8-4           cluster_2.1.8.1        beeswarm_0.4.0         paletteer_1.6.0        cli_3.6.5              compiler_4.5.0         crayon_1.5.3          
[129] future.apply_1.20.0    labeling_0.4.3         rematch2_2.1.2         ps_1.9.1               plyr_1.8.9             fs_1.6.6               ggbeeswarm_0.7.2       stringi_1.8.7         
[137] viridisLite_0.4.2      deldir_2.0-4           lazyeval_0.2.2         devtools_2.4.6         spatstat.geom_3.6-0    Matrix_1.7-4           RcppHNSW_0.6.0         hms_1.1.3             
[145] future_1.67.0          Rhdf5lib_1.30.0        shiny_1.11.1           qs_0.27.3              ROCR_1.0-11            igraph_2.1.4           memoise_2.0.1          RcppParallel_5.1.11-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions