Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CellDimPlot custom colors can't be sorted in their own order #12

Open
bionoob7 opened this issue Nov 21, 2024 · 1 comment
Open

CellDimPlot custom colors can't be sorted in their own order #12

bionoob7 opened this issue Nov 21, 2024 · 1 comment

Comments

@bionoob7
Copy link

非常感谢您制作这款包,我为每个细胞类型指定了颜色,但是函数还是会按照颜色顺序而不是指定的细胞类型所对应的顺序上色

library(Seurat)
library(scplotter)
data(pancreas_sub)
Idents(pancreas_sub) <- "SubCellType"
table(Idents(pancreas_sub))
# Ductal   Ngn3 low EP  Ngn3 high EP Pre-endocrine 
# 239            81           168           150 
# Beta         Alpha         Delta       Epsilon 
# 177           135            18            32
cell_color <- c(
  "Ductal" = "#4E79A7FF",
  "Delta" = "#B07AA1FF",
  "Alpha" = "#EDC948FF",
  "Ngn3 low EP" = "#F28E2BFF",
  "Ngn3 high EP" = "#E15759FF",
  "Pre-endocrine" = "#76B7B2FF",
  "Beta" = "#59A14FFF",
  "Epsilon" = "#FF9DA7FF"
)

CellDimPlot(pancreas_sub, group_by = "SubCellType", reduction = "UMAP",
            palcolor = cell_color)

image

image

可以看到颜色并不是一样对应的,当我把SubCellType指定为factor时,问题依然存在,并且不是个案,我在win和linux上均复现成功

sessionInfo()
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: Asia/Shanghai
tzcode source: internal

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

other attached packages:
[1] ggsci_3.2.0        scplotter_0.1.0    Seurat_5.1.0       SeuratObject_5.0.2
[5] sp_2.1-4           paletteer_1.6.0    pacman_0.5.1      

loaded via a namespace (and not attached):
  [1] cubature_2.1.1              RcppAnnoy_0.0.22           
  [3] splines_4.4.1               later_1.3.2                
  [5] prismatic_1.1.2             tibble_3.2.1               
  [7] polyclip_1.10-7             fastDummies_1.7.4          
  [9] lifecycle_1.0.4             globals_0.16.3             
 [11] lattice_0.22-6              MASS_7.3-61                
 [13] magrittr_2.0.3              plotly_4.10.4              
 [15] httpuv_1.6.15               sctransform_0.4.1          
 [17] spam_2.11-0                 spatstat.sparse_3.1-0      
 [19] reticulate_1.39.0           cowplot_1.1.3              
 [21] pbapply_1.7-2               RColorBrewer_1.1-3         
 [23] abind_1.4-8                 zlibbioc_1.50.0            
 [25] Rtsne_0.17                  GenomicRanges_1.56.2       
 [27] purrr_1.0.2                 ggraph_2.2.1               
 [29] BiocGenerics_0.50.0         tweenr_2.0.3               
 [31] evmix_2.12                  circlize_0.4.16            
 [33] GenomeInfoDbData_1.2.12     IRanges_2.38.1             
 [35] S4Vectors_0.42.1            ggrepel_0.9.6              
 [37] irlba_2.3.5.1               listenv_0.9.1              
 [39] spatstat.utils_3.1-0        iNEXT_3.0.1                
 [41] MatrixModels_0.5-3          goftest_1.2-3              
 [43] RSpectra_0.16-2             scRepertoire_2.0.8         
 [45] spatstat.random_3.3-2       fitdistrplus_1.2-1         
 [47] parallelly_1.38.0           leiden_0.4.3.1             
 [49] codetools_0.2-20            DelayedArray_0.30.1        
 [51] xml2_1.3.6                  ggforce_0.4.2              
 [53] tidyselect_1.2.1            shape_1.4.6.1              
 [55] UCSC.utils_1.0.0            farver_2.1.2               
 [57] viridis_0.6.5               matrixStats_1.4.1          
 [59] stats4_4.4.1                spatstat.explore_3.3-3     
 [61] jsonlite_1.8.9              tidygraph_1.3.1            
 [63] progressr_0.15.0            ggridges_0.5.6             
 [65] ggalluvial_0.12.5           survival_3.7-0             
 [67] tools_4.4.1                 ggnewscale_0.5.0           
 [69] stringdist_0.9.12           ica_1.0-3                  
 [71] Rcpp_1.0.13-1               glue_1.8.0                 
 [73] gridExtra_2.3               SparseArray_1.4.8          
 [75] MatrixGenerics_1.16.0       GenomeInfoDb_1.40.1        
 [77] dplyr_1.1.4                 withr_3.0.2                
 [79] fastmap_1.2.0               fansi_1.0.6                
 [81] SparseM_1.84-2              digest_0.6.37              
 [83] R6_2.5.1                    mime_0.12                  
 [85] colorspace_2.1-1            scattermore_1.2            
 [87] tensor_1.5                  spatstat.data_3.1-2        
 [89] utf8_1.2.4                  tidyr_1.3.1                
 [91] generics_0.1.3              data.table_1.16.2          
 [93] graphlayouts_1.2.0          httr_1.4.7                 
 [95] htmlwidgets_1.6.4           S4Arrays_1.4.1             
 [97] uwot_0.2.2                  pkgconfig_2.0.3            
 [99] gtable_0.3.6                lmtest_0.9-40              
[101] SingleCellExperiment_1.26.0 XVector_0.44.0             
[103] htmltools_0.5.8.1           dotCall64_1.2              
[105] scales_1.3.0                Biobase_2.64.0             
[107] png_0.1-8                   spatstat.univar_3.0-1      
[109] ggdendro_0.2.0              rstudioapi_0.17.1          
[111] rjson_0.2.23                reshape2_1.4.4             
[113] nlme_3.1-166                cachem_1.1.0               
[115] zoo_1.8-12                  GlobalOptions_0.1.2        
[117] stringr_1.5.1               KernSmooth_2.23-24         
[119] parallel_4.4.1              miniUI_0.1.1.1             
[121] pillar_1.9.0                grid_4.4.1                 
[123] vctrs_0.6.5                 RANN_2.6.2                 
[125] VGAM_1.1-12                 promises_1.3.0             
[127] xtable_1.8-4                cluster_2.1.6              
[129] truncdist_1.0-2             cli_3.6.3                  
[131] compiler_4.4.1              rlang_1.1.4                
[133] crayon_1.5.3                future.apply_1.11.3        
[135] labeling_0.4.3              rematch2_2.1.2             
[137] plyr_1.8.9                  forcats_1.0.0              
[139] stringi_1.8.4               viridisLite_0.4.2          
[141] deldir_2.0-4                assertthat_0.2.1           
[143] munsell_0.5.1               gsl_2.1-8                  
[145] lazyeval_0.2.2              spatstat.geom_3.3-3        
[147] quantreg_5.99               Matrix_1.7-0               
[149] RcppHNSW_0.6.0              patchwork_1.3.0            
[151] future_1.34.0               ggplot2_3.5.1              
[153] shiny_1.9.1                 plotthis_0.3.5             
[155] SummarizedExperiment_1.34.0 evd_2.3-7.1                
[157] ROCR_1.0-11                 gridtext_0.1.5             
[159] igraph_2.1.1                memoise_2.0.1
@pwwang
Copy link
Owner

pwwang commented Nov 21, 2024

It should work with the latest plotthis

Try remotes::install_github("pwwang/plotthis").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants