samuel-marsh/scCustomize

plot_median = TRUE does not work in VlnPlot_scCustom when features contains more than one gene

Closed this issue · 1 comments

Hello,
Thanks for all your amazing work!

Everything is in the title. Actually, plot_median = TRUE works but only for the last gene...
Here is a minimal example:

library(Seurat)
library(SeuratData)
library(scCustomize)

data("pbmc3k")
pbmc3k = UpdateSeuratObject(pbmc3k)

pbmc3k = NormalizeData(object = pbmc3k)
pbmc3k = FindVariableFeatures(object = pbmc3k)
pbmc3k = ScaleData(object = pbmc3k)
pbmc3k = RunPCA(object = pbmc3k)
pbmc3k = RunUMAP(object = pbmc3k, dims = 1:20)
pbmc3k = FindNeighbors(object = pbmc3k, dims = 1:20)
pbmc3k = FindClusters(object = pbmc3k, resolution = 0.50)

DimPlot_scCustom(seurat_object = pbmc3k, group.by = "seurat_clusters")

image_1

The following code works if only one gene is in feature =

FeaturePlot_scCustom(seurat_object = pbmc3k, features = "GAPDH") /
VlnPlot_scCustom(seurat_object = pbmc3k, group.by = "seurat_clusters", features = "GAPDH", plot_median = TRUE) & NoLegend()

image_2

But the following codes do not work if several genes are in feature =

FeaturePlot_scCustom(seurat_object = pbmc3k, features = c("GAPDH", "VIM"), num_columns = 2) /
VlnPlot_scCustom(seurat_object = pbmc3k, group.by = "seurat_clusters", features = c("GAPDH", "VIM"), plot_median = TRUE, num_columns = 2)

FeaturePlot_scCustom(seurat_object = pbmc3k, features = c("GAPDH", "VIM", "RPS18"), num_columns = 3) /
VlnPlot_scCustom(seurat_object = pbmc3k, group.by = "seurat_clusters", features = c("GAPDH", "VIM", "RPS18"), plot_median = TRUE, num_columns = 3)

image_3
image_4

I tried these codes, but it didn't work... Plus, using these codes, I don't see any median at all in the plots, and no warning in the console.

FeaturePlot_scCustom(seurat_object = pbmc3k, features = c("GAPDH", "VIM"), num_columns = 2) /
VlnPlot_scCustom(seurat_object = pbmc3k, group.by = "seurat_clusters", features = c("GAPDH", "VIM"), plot_median = c(TRUE, TRUE), num_columns = 2)

FeaturePlot_scCustom(seurat_object = pbmc3k, features = c("GAPDH", "VIM"), num_columns = 2) /
VlnPlot_scCustom(seurat_object = pbmc3k, group.by = "seurat_clusters", features = c("GAPDH", "VIM"), plot_median = list(TRUE, TRUE), num_columns = 2)

image_5

Thanks in advance for solving this issue,
Best regards,

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.7.4

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] C

time zone: Europe/Paris
tzcode source: internal

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

other attached packages:
[1] scCustomize_2.0.1       pbmc3k.SeuratData_3.1.4 ifnb.SeuratData_3.1.0  
[4] SeuratData_0.2.2.9001   Seurat_5.0.1            SeuratObject_5.0.1     
[7] sp_2.1-3               

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     jsonlite_1.8.8         shape_1.4.6           
  [4] magrittr_2.0.3         spatstat.utils_3.0-4   ggbeeswarm_0.7.2      
  [7] farver_2.1.1           GlobalOptions_0.1.2    vctrs_0.6.5           
 [10] ROCR_1.0-11            spatstat.explore_3.2-6 paletteer_1.6.0       
 [13] janitor_2.2.0          htmltools_0.5.7        forcats_1.0.0         
 [16] sctransform_0.4.1      parallelly_1.36.0      KernSmooth_2.23-22    
 [19] htmlwidgets_1.6.4      ica_1.0-3              plyr_1.8.9            
 [22] lubridate_1.9.3        plotly_4.10.4          zoo_1.8-12            
 [25] igraph_2.0.1.1         mime_0.12              lifecycle_1.0.4       
 [28] pkgconfig_2.0.3        Matrix_1.6-5           R6_2.5.1              
 [31] fastmap_1.1.1          snakecase_0.11.1       fitdistrplus_1.1-11   
 [34] future_1.33.1          shiny_1.8.0            digest_0.6.34         
 [37] colorspace_2.1-0       rematch2_2.1.2         patchwork_1.2.0       
 [40] tensor_1.5             RSpectra_0.16-1        irlba_2.3.5.1         
 [43] labeling_0.4.3         progressr_0.14.0       timechange_0.3.0      
 [46] fansi_1.0.6            spatstat.sparse_3.0-3  httr_1.4.7            
 [49] polyclip_1.10-6        abind_1.4-5            compiler_4.3.1        
 [52] withr_3.0.0            fastDummies_1.7.3      MASS_7.3-60.0.1       
 [55] rappdirs_0.3.3         tools_4.3.1            vipor_0.4.7           
 [58] lmtest_0.9-40          beeswarm_0.4.0         httpuv_1.6.14         
 [61] future.apply_1.11.1    goftest_1.2-3          glue_1.7.0            
 [64] nlme_3.1-164           promises_1.2.1         grid_4.3.1            
 [67] Rtsne_0.17             cluster_2.1.6          reshape2_1.4.4        
 [70] generics_0.1.3         gtable_0.3.4           spatstat.data_3.0-4   
 [73] tidyr_1.3.1            data.table_1.15.0      utf8_1.2.4            
 [76] spatstat.geom_3.2-8    RcppAnnoy_0.0.22       ggrepel_0.9.5         
 [79] RANN_2.6.1             pillar_1.9.0           stringr_1.5.1         
 [82] spam_2.10-0            RcppHNSW_0.6.0         ggprism_1.0.4         
 [85] later_1.3.2            circlize_0.4.16        splines_4.3.1         
 [88] dplyr_1.1.4            lattice_0.22-5         survival_3.5-7        
 [91] deldir_2.0-2           tidyselect_1.2.0       miniUI_0.1.1.1        
 [94] pbapply_1.7-2          gridExtra_2.3          scattermore_1.2       
 [97] matrixStats_1.2.0      stringi_1.8.3          lazyeval_0.2.2        
[100] codetools_0.2-19       tibble_3.2.1           cli_3.6.2             
[103] uwot_0.1.16            xtable_1.8-4           reticulate_1.35.0     
[106] munsell_0.5.0          Rcpp_1.0.12            globals_0.16.2        
[109] spatstat.random_3.2-2  png_0.1-8              ggrastr_1.0.2         
[112] parallel_4.3.1         ellipsis_0.3.2         ggplot2_3.4.4         
[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            crayon_1.5.2           rlang_1.1.3           
[124] cowplot_1.1.3

Hi @CroixJeremy2,

Thanks for kind words! Thanks for finding bug. I have just fixed this in the develop branch (v2.1.2.9022 or greater). If the issue persists after installing the dev branch please let me know and I'll reopen the issue.

Best,
Sam