enblacar / SCpubr

Generate high quality, publication ready visualizations for single cell transcriptomics data.
https://enblacar.github.io/SCpubr-book/
GNU General Public License v3.0
150 stars 12 forks source link

BUG | do_FeaturePlot | scale = T stopped working #69

Closed laleaton closed 2 months ago

laleaton commented 2 months ago

-->

Bug:

# Within this past week I have been making dotplots with the scale parameter set to True. Today, I updated the package due to issue #68 that you closed as I was having the same issue as original issue poster. While this fixed my labelling in do_FeaturePlot(), my scale parameter seems not to be functioning.. any ideas?
Thank you!

Reproducible example:

# working plot without scale function
SCpubr::do_DotPlot(sample = data_test_filtered_harmony, features = goi1, cluster = T)
[Rplot.pdf](https://github.com/user-attachments/files/16256762/Rplot.pdf)

# when it fails
SCpubr::do_DotPlot(sample = data_test_filtered_harmony, features = goi1, cluster = T, scale = T)

Error log:

Error in SCpubr::do_DotPlot(sample = data_test_filtered_harmony, features = goi1,  : 
  unused argument (scale = T)

SCpubr version:

[1] '2.0.2.9000'

Session info:

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Denver
tzcode source: system (glibc)

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

other attached packages:
 [1] SCpubr_2.0.2.9000           RcppCNPy_0.2.12             reticulate_1.38.0          
 [4] SeuratDisk_0.0.0.9021       BPCells_0.2.0               ggrepel_0.9.5              
 [7] lisi_1.0                    MetBrewer_0.2.0             ggsci_3.1.0                
[10] clusterProfiler_4.12.0      VISION_3.0.1                metap_1.10                 
[13] gridExtra_2.3               ggpubr_0.6.0                harmony_1.2.0              
[16] Rcpp_1.0.12                 SeuratWrappers_0.3.5        ensembldb_2.28.0           
[19] GenomicFeatures_1.56.0      AnnotationDbi_1.66.0        AnnotationFilter_1.28.0    
[22] AnnotationHub_3.12.0        BiocFileCache_2.12.0        dbplyr_2.5.0               
[25] RCurl_1.98-1.14             cowplot_1.1.3               scales_1.3.0               
[28] Matrix_1.7-0                lubridate_1.9.3             forcats_1.0.0              
[31] stringr_1.5.1               dplyr_1.1.4                 purrr_1.0.2                
[34] readr_2.1.5                 tidyr_1.3.1                 tibble_3.2.1               
[37] ggplot2_3.5.1               tidyverse_2.0.0             SingleCellExperiment_1.26.0
[40] SummarizedExperiment_1.34.0 Biobase_2.64.0              GenomicRanges_1.56.0       
[43] GenomeInfoDb_1.40.1         IRanges_2.38.0              S4Vectors_0.42.0           
[46] BiocGenerics_0.50.0         MatrixGenerics_1.16.0       matrixStats_1.3.0          
[49] Seurat_5.1.0                SeuratObject_5.0.2          sp_2.1-4                   

loaded via a namespace (and not attached):
  [1] R.methodsS3_1.8.2        goftest_1.2-3            Biostrings_2.72.1       
  [4] TH.data_1.1-2            vctrs_0.6.5              spatstat.random_3.2-3   
  [7] plumber_1.2.2            digest_0.6.36            png_0.1-8               
 [10] deldir_2.0-4             parallelly_1.37.1        permute_0.9-7           
 [13] MASS_7.3-60.2            reshape2_1.4.4           httpuv_1.6.15           
 [16] qvalue_2.36.0            withr_3.0.0              ggfun_0.1.5             
 [19] survival_3.7-0           memoise_2.0.1            gson_0.1.0              
 [22] tidytree_0.4.6           zoo_1.8-12               pbapply_1.7-2           
 [25] R.oo_1.26.0              logging_0.10-108         KEGGREST_1.44.0         
 [28] promises_1.3.0           httr_1.4.7               rstatix_0.7.2           
 [31] restfulr_0.0.15          globals_0.16.3           fitdistrplus_1.1-11     
 [34] rstudioapi_0.16.0        UCSC.utils_1.0.0         miniUI_0.1.1.1          
 [37] generics_0.1.3           DOSE_3.30.1              sparsesvd_0.2-2         
 [40] curl_5.2.1               zlibbioc_1.50.0          ggraph_2.2.1            
 [43] polyclip_1.10-6          TFisher_0.2.0            GenomeInfoDbData_1.2.12 
 [46] quadprog_1.5-8           SparseArray_1.4.8        xtable_1.8-4            
 [49] S4Arrays_1.4.1           hms_1.1.3                webutils_1.2.0          
 [52] irlba_2.3.5.1            colorspace_2.1-0         filelock_1.0.3          
 [55] hdf5r_1.3.10             ROCR_1.0-11              spatstat.data_3.1-2     
 [58] magrittr_2.0.3           lmtest_0.9-40            ggtree_3.12.0           
 [61] later_1.3.2              viridis_0.6.5            lattice_0.22-5          
 [64] spatstat.geom_3.2-9      future.apply_1.11.2      iotools_0.3-5           
 [67] shadowtext_0.1.3         scattermore_1.2          XML_3.99-0.16.1         
 [70] RcppAnnoy_0.0.22         pillar_1.9.0             nlme_3.1-165            
 [73] compiler_4.4.1           RSpectra_0.16-1          stringi_1.8.4           
 [76] tensor_1.5               GenomicAlignments_1.40.0 plyr_1.8.9              
 [79] crayon_1.5.3             abind_1.4-5              BiocIO_1.14.0           
 [82] gridGraphics_0.5-1       sn_2.1.1                 graphlayouts_1.1.1      
 [85] bit_4.0.5                mathjaxr_1.6-0           sandwich_3.1-0          
 [88] fastmatch_1.1-4          codetools_0.2-19         multcomp_1.4-25         
 [91] plotly_4.10.4            multtest_2.60.0          mime_0.12               
 [94] splines_4.4.1            fastDummies_1.7.3        HDO.db_0.99.1           
 [97] blob_1.2.4               utf8_1.2.4               BiocVersion_3.19.1      
[100] fs_1.6.4                 listenv_0.9.1            Rdpack_2.6              
[103] ggsignif_0.6.4           ggplotify_0.1.2          statmod_1.5.0           
[106] tzdb_0.4.0               tweenr_2.0.3             pkgconfig_2.0.3         
[109] tools_4.4.1              cachem_1.1.0             RhpcBLASctl_0.23-42     
[112] rbibutils_2.2.16         RSQLite_2.3.7            viridisLite_0.4.2       
[115] DBI_1.2.3                numDeriv_2016.8-1.1      wordspace_0.2-8         
[118] fastmap_1.2.0            grid_4.4.1               pbmcapply_1.5.1         
[121] ica_1.0-3                Rsamtools_2.20.0         broom_1.0.6             
[124] patchwork_1.2.0          BiocManager_1.30.23      dotCall64_1.1-1         
[127] carData_3.0-5            RANN_2.6.1               farver_2.1.2            
[130] scatterpie_0.2.3         tidygraph_1.3.1          mgcv_1.9-1              
[133] yaml_2.3.8               rtracklayer_1.64.0       cli_3.6.3               
[136] leiden_0.4.3.1           lifecycle_1.0.4          uwot_0.2.2              
[139] mvtnorm_1.2-5            presto_1.0.0             backports_1.5.0         
[142] BiocParallel_1.38.0      timechange_0.3.0         gtable_0.3.5            
[145] rjson_0.2.21             ggridges_0.5.6           progressr_0.14.0        
[148] limma_3.60.2             parallel_4.4.1           ape_5.8                 
[151] jsonlite_1.8.8           RcppHNSW_0.6.0           bitops_1.0-7            
[154] assertthat_0.2.1         bit64_4.0.5              loe_1.1                 
[157] qqconf_1.3.2             Rtsne_0.17               yulab.utils_0.1.4       
[160] vegan_2.6-6.1            spatstat.utils_3.0-5     mutoss_0.1-13           
[163] GOSemSim_2.30.0          R.utils_2.12.3           lazyeval_0.2.2          
[166] shiny_1.8.1.1            htmltools_0.5.8.1        enrichplot_1.24.0       
[169] GO.db_3.19.1             sctransform_0.4.1        rappdirs_0.3.3          
[172] glue_1.7.0               spam_2.10-0              XVector_0.44.0          
[175] treeio_1.28.0            mclust_6.1.1             mnormt_2.1.1            
[178] igraph_2.0.3             R6_2.5.1                 labeling_0.4.3          
[181] cluster_2.1.6            aplot_0.2.2              swagger_3.33.1          
[184] DelayedArray_0.30.1      tidyselect_1.2.1         plotrix_3.8-4           
[187] ProtGenerics_1.36.0      ggforce_0.4.2            car_3.1-2               
[190] future_1.33.2            fastICA_1.2-4            rsvd_1.0.5              
[193] munsell_0.5.1            KernSmooth_2.23-24       data.table_1.15.4       
[196] htmlwidgets_1.6.4        fgsea_1.30.0             RColorBrewer_1.1-3      
[199] rlang_1.1.4              spatstat.sparse_3.1-0    spatstat.explore_3.2-7  
[202] remotes_2.5.0            phangorn_2.11.1          fansi_1.0.6  
enblacar commented 2 months ago

Hi @laleaton,

Thanks for using my package!

Please keep in mind that you downloaded theHEAD commit of the R package. This means that you are just currently using the R package as I am right now as the developer, it all its beauty and "bugginess" ahhahaha If you ever consider downloading the "development" versions of the package, always refer to the official Releases, which I incorporate with every CRAN update.

This said, for the next CRAN version I have refactored the SCpubr::do_DotPlot() function entirely, removing the dependency with Seurat::DotPlot(). This means I am no longer using the native function from Seurat as the basis of the plot, but rather generating my own version of the dot plot. This also means that I am no longer using the scale parameter, as this was using the Seurat's scaling implementation. I have on my to-do list to allow for z-scoring of the values, if desired, but this is yet to be implemented. It will definitely roll out on the next CRAN update, though. Yet, this might not end up being exactly the same as with Seurat.

I can give you a heads up when I implement it, if you want! For the time being, please revert to the CRAN version if you want to still use the scale parameter.

I hope this was helpful! Enrique

laleaton commented 2 months ago

Thank you Enrique! Yes, please do let me know when you implement scaling. I really appreciate your prompt and thorough response! Cheers, Laura Ann

enblacar commented 2 months ago

Hi @laleaton,

I performed a quick implementation of the Z-scoring on a gene-basis in do_DotPlot(). This allows to set the distribution of the Avg. Expression of a given gene across the groups so that the mean is 0 and standard deviation is 1. This allows you to quickly check which group/s have the highest avg. expression values for a given gene, but you should then avoid performing gene-wise comparisons.

This said:

You can access this under the latest commit. Please be aware that you are again downloading the most recent and potentially buggy version of the pacakge!

devtools::install_github("enblacar/SCpubr", ref = "af2828dbfce7a11562a0f6d3fc447122fbf66670")

Hope this helps! Enrique