-
Notifications
You must be signed in to change notification settings - Fork 976
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hey Seurat team!
Desciption of issue
I'm running FeaturePlot with two features (one from metadata, one expression) using both blend = TRUE, split.by = "<split_var> and I'm getting the below error:
Error in `palette()`:
! Insufficient values in manual scale. 1 needed but only 0 provided.
Run `rlang::last_trace()` to see where the error occurred.Proposed Solution
When I debugged the error, I found out it happens when one of the features per split provided to BlendExpression is constant, min-max normalization within BlendExpression returns NaN, yielding unusable output data.
I attempted to fix this in #8486 by making the normalization in BlendExpression return 0 if the given feature is constant, which has resolved the issue locally. However, I wanted to describe the bug in more detail, in case there might be a better solution.
Reproducible Example
Here's a reproducible example using pbmc_small:
library(Seurat)
set.seed(123)
test_metadata <- data.frame(
test_var1 = runif(ncol(pbmc_small)),
test_var2 = ifelse(pbmc_small$groups == "g1", 0.5, runif(1)),
row.names = colnames(pbmc_small)
)
pbmc_small <- AddMetaData(pbmc_small, test_metadata)
FeaturePlot(pbmc_small, features = c("test_var1", "CD79B"), blend = TRUE, split.by = "groups")
# works OK and produces the plot
FeaturePlot(pbmc_small, features = c("test_var2", "CD79B"), blend = TRUE, split.by = "groups")
# raises:
# Error in `palette()`:
# ! Insufficient values in manual scale. 1 needed but only 0 provided.
# Run `rlang::last_trace()` to see where the error occurred.sessionInfo:
R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.1.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.3-x86_64/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: Europe/London
tzcode source: internal
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] Seurat_5.0.1 SeuratObject_5.0.1 sp_2.1-2
loaded via a namespace (and not attached):
[1] deldir_2.0-2 pbapply_1.7-2 gridExtra_2.3 rlang_1.1.2 magrittr_2.0.3 RcppAnnoy_0.0.21
[7] spatstat.geom_3.2-7 matrixStats_1.1.0 ggridges_0.5.4 compiler_4.3.2 png_0.1-8 vctrs_0.6.5
[13] reshape2_1.4.4 stringr_1.5.1 pkgconfig_2.0.3 fastmap_1.1.1 ellipsis_0.3.2 labeling_0.4.3
[19] utf8_1.2.4 promises_1.2.1 purrr_1.0.2 jsonlite_1.8.8 goftest_1.2-3 later_1.3.2
[25] spatstat.utils_3.0-4 irlba_2.3.5.1 parallel_4.3.2 cluster_2.1.4 R6_2.5.1 ica_1.0-3
[31] stringi_1.8.2 RColorBrewer_1.1-3 spatstat.data_3.0-3 reticulate_1.34.0 parallelly_1.36.0 lmtest_0.9-40
[37] scattermore_1.2 Rcpp_1.0.11 tensor_1.5 future.apply_1.11.0 zoo_1.8-12 sctransform_0.4.1
[43] httpuv_1.6.13 Matrix_1.6-3 splines_4.3.2 igraph_1.5.1 tidyselect_1.2.0 abind_1.4-5
[49] rstudioapi_0.15.0 spatstat.random_3.2-2 codetools_0.2-19 miniUI_0.1.1.1 spatstat.explore_3.2-5 listenv_0.9.0
[55] lattice_0.21-9 tibble_3.2.1 plyr_1.8.9 withr_2.5.2 shiny_1.8.0 ROCR_1.0-11
[61] Rtsne_0.17 future_1.33.0 fastDummies_1.7.3 survival_3.5-7 polyclip_1.10-6 fitdistrplus_1.1-11
[67] pillar_1.9.0 BiocManager_1.30.22 KernSmooth_2.23-22 renv_1.0.3 plotly_4.10.3 generics_0.1.3
[73] RcppHNSW_0.5.0 ggplot2_3.4.4 munsell_0.5.0 scales_1.3.0 globals_0.16.2 xtable_1.8-4
[79] glue_1.6.2 lazyeval_0.2.2 tools_4.3.2 data.table_1.14.10 RSpectra_0.16-1 RANN_2.6.1
[85] leiden_0.4.3.1 dotCall64_1.1-1 cowplot_1.1.1 grid_4.3.2 tidyr_1.3.0 colorspace_2.1-0
[91] nlme_3.1-163 patchwork_1.1.3 cli_3.6.1 spatstat.sparse_3.0-3 spam_2.10-0 fansi_1.0.6
[97] viridisLite_0.4.2 dplyr_1.1.4 uwot_0.1.16 gtable_0.3.4 digest_0.6.33 progressr_0.14.0
[103] ggrepel_0.9.4 farver_2.1.1 htmlwidgets_1.6.4 htmltools_0.5.7 lifecycle_1.0.4 httr_1.4.7
[109] mime_0.12 MASS_7.3-60 Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working