"split.by" option in Cluster Highlight Plot caused error · Issue #201 · samuel-marsh/scCustomize (original) (raw)
Dear Sam,
I was trying to visualize (highlight) several clusters of interest in my integrated Seurat data.
I wanted to first generate a plot highlighting all the cells from a cluster, and then another plot showing the cells from each individual sample.
The first plot went perfect with the Cluster_Highlight_Plot()
function, but somehow the second plot could not be generated as expected.
The code for the first plot is straightforward:
Cluster_Highlight_Plot(exp_data, reduction='umap.integrated', cluster_name=1, highlight_color="#E69F00")
Based on this, the code for the second plot should be similar, with just one tiny modification by specifying the split.by
option
Cluster_Highlight_Plot(exp_data, reduction='umap.integrated', cluster_name=1, highlight_color="#E69F00", split.by='orig.ident')
However, somehow an error message showed up:
Error in names(colors_overall) <- levels_overall :
'names' attribute [33] must be the same length as the vector [1]
Not sure why this happened, but it seems that specifying only one color for the whole cluster does not work?
As I have two samples in this integrated data, I also tried specifying highlight_color =
with two colors (different colors for different samples). Somehow this didn't work either.
To add, setting different colors for different samples did not work in the original Seurat function DimPlot()
either:
DimPlot(exp_data, reduction = 'umap.integrated', cells.highlight = cells_to_highlight, cols.highlight = "#E69F00", # Only accept one color for the "split" plot sizes.highlight = 0.3, raster = FALSE, split.by = "orig.ident", ncol = nSamples )
Hope this report can help improve the package.
Thank you so much.
Best regards,
Jason Leong
sessionInfo() output
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.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.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.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: Asia/Macau
tzcode source: internal
attached base packages:
[1] tools stats graphics grDevices utils datasets methods base
other attached packages:
[1] jsonlite_1.8.8 mongolite_2.8.0 scCustomize_2.1.2 SeuratDisk_0.0.0.9021 Seurat_5.1.0 SeuratObject_5.0.2 sp_2.1-4
[8] Matrix_1.7-0 plotly_4.10.4 colorspace_2.1-1 RColorBrewer_1.1-3 viridis_0.6.5 viridisLite_0.4.2 cowplot_1.1.3
[15] hms_1.1.3 glue_1.7.0 lubridate_1.9.3 forcats_1.0.0 purrr_1.0.2 tibble_3.2.1 ggplot2_3.5.1
[22] tidyverse_2.0.0 stringr_1.5.1 dplyr_1.1.4 tidyr_1.3.1 readr_2.1.5 renv_1.0.7
loaded via a namespace (and not attached):
[1] RcppAnnoy_0.0.22 splines_4.4.1 later_1.3.2 prismatic_1.1.2 polyclip_1.10-7
[6] janitor_2.2.0 fastDummies_1.7.3 lifecycle_1.0.4 globals_0.16.3 lattice_0.22-6
[11] vroom_1.6.5 hdf5r_1.3.11 MASS_7.3-61 crosstalk_1.2.1 magrittr_2.0.3
[16] rmarkdown_2.27 yaml_2.3.10 httpuv_1.6.15 glmGamPoi_1.14.3 sctransform_0.4.1
[21] spam_2.10-0 askpass_1.2.0 spatstat.sparse_3.1-0 reticulate_1.38.0 pbapply_1.7-2
[26] abind_1.4-5 zlibbioc_1.50.0 Rtsne_0.17 GenomicRanges_1.56.1 BiocGenerics_0.50.0
[31] circlize_0.4.16 GenomeInfoDbData_1.2.12 IRanges_2.38.1 S4Vectors_0.42.1 ggrepel_0.9.5
[36] irlba_2.3.5.1 listenv_0.9.1 spatstat.utils_3.0-5 pheatmap_1.0.12 goftest_1.2-3
[41] RSpectra_0.16-2 spatstat.random_3.3-1 fitdistrplus_1.2-1 parallelly_1.38.0 DelayedMatrixStats_1.26.0
[46] leiden_0.4.3.1 codetools_0.2-20 DelayedArray_0.30.1 tidyselect_1.2.1 shape_1.4.6.1
[51] farver_2.1.2 UCSC.utils_1.0.0 matrixStats_1.3.0 stats4_4.4.1 spatstat.explore_3.3-1
[56] progressr_0.14.0 ggridges_0.5.6 survival_3.7-0 systemfonts_1.1.0 ragg_1.3.2
[61] ica_1.0-3 Rcpp_1.0.13 gridExtra_2.3 SparseArray_1.4.8 xfun_0.46
[66] MatrixGenerics_1.16.0 GenomeInfoDb_1.40.1 withr_3.0.1 fastmap_1.2.0 fansi_1.0.6
[71] openssl_2.2.0 digest_0.6.36 timechange_0.3.0 R6_2.5.1 mime_0.12
[76] textshaping_0.4.0 ggprism_1.0.5 scattermore_1.2 tensor_1.5 spatstat.data_3.1-2
[81] utf8_1.2.4 generics_0.1.3 data.table_1.15.4 httr_1.4.7 htmlwidgets_1.6.4
[86] S4Arrays_1.4.1 uwot_0.2.2 pkgconfig_2.0.3 gtable_0.3.5 lmtest_0.9-40
[91] SingleCellExperiment_1.26.0 XVector_0.44.0 htmltools_0.5.8.1 dotCall64_1.1-1 scales_1.3.0
[96] Biobase_2.64.0 png_0.1-8 spatstat.univar_3.0-0 snakecase_0.11.1 knitr_1.48
[101] rstudioapi_0.16.0 tzdb_0.4.0 reshape2_1.4.4 nlme_3.1-165 zoo_1.8-12
[106] GlobalOptions_0.1.2 KernSmooth_2.23-24 parallel_4.4.1 miniUI_0.1.1.1 vipor_0.4.7
[111] ggrastr_1.0.2 pillar_1.9.0 grid_4.4.1 vctrs_0.6.5 RANN_2.6.1
[116] promises_1.3.0 dittoSeq_1.16.0 xtable_1.8-4 cluster_2.1.6 beeswarm_0.4.0
[121] paletteer_1.6.0 evaluate_0.24.0 cli_3.6.3 compiler_4.4.1 rlang_1.1.4
[126] crayon_1.5.3 future.apply_1.11.2 labeling_0.4.3 rematch2_2.1.2 plyr_1.8.9
[131] ggbeeswarm_0.7.2 stringi_1.8.4 deldir_2.0-4 munsell_0.5.1 lazyeval_0.2.2
[136] spatstat.geom_3.3-2 RcppHNSW_0.6.0 patchwork_1.2.0 sparseMatrixStats_1.16.0 bit64_4.0.5
[141] future_1.34.0 shiny_1.9.1 SummarizedExperiment_1.34.0 ROCR_1.0-11 igraph_2.0.3
[146] bit_4.0.5