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
157 stars 12 forks source link

BUG | do_VolcanoPlot | add gene tags based on logFC + pvalue #63

Closed StefanosVoglis closed 6 months ago

StefanosVoglis commented 6 months ago

Hi, great package, thanks for all the effort you put into this!

Bug:

When trying to plot a volcano plot using do_VolcanoPlot, I have the impression that order_tags_by = "both" somehow messes up the plot since the gene labels are not put on genes which are within the defined threshholds for p-vallue and logFC, and not on both sides of the logFC cutoffs. 
However when trying order_tags_by = "pvalue" or order_tags_by = "logfc" the function works nicely. 

Reproducible example:

library(SeuratData)
pbmc <- LoadData("pbmc3k", type = "pbmc3k.final")
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
pbmc <- ScaleData(pbmc)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)

cluster2.markers <- FindMarkers(pbmc, ident.1 = 2)

SCpubr::do_VolcanoPlot(sample = pbmc,
                            de_genes = cluster2.markers,
                            order_tags_by = "both")

image

SCpubr version:

2.0.2.9000

Session info:

R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

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

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

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
 [1] pbmc3k.SeuratData_3.1.4 SeuratData_0.2.2.9001   EnhancedVolcano_1.18.0  ggrepel_0.9.5           Scillus_0.5.0          
 [6] SCpubr_2.0.2.9000       ComplexHeatmap_2.18.0   patchwork_1.2.0.9000    scCustomize_2.1.2       viridis_0.6.5          
[11] viridisLite_0.4.2       clustree_0.5.1          ggraph_2.2.1            dittoSeq_1.12.2         FastIntegration_1.1.0  
[16] data.table_1.15.4       lubridate_1.9.3         forcats_1.0.0           stringr_1.5.1           dplyr_1.1.4            
[21] purrr_1.0.2             readr_2.1.5             tidyr_1.3.1             tibble_3.2.1            ggplot2_3.5.0          
[26] tidyverse_2.0.0         Seurat_5.0.3            SeuratObject_5.0.1      sp_2.1-3                Matrix_1.6-5           

loaded via a namespace (and not attached):
  [1] fs_1.6.3                    matrixStats_1.3.0           spatstat.sparse_3.0-3       bitops_1.0-7                devtools_2.4.5             
  [6] httr_1.4.7                  RColorBrewer_1.1-3          doParallel_1.0.17           profvis_0.3.8               tools_4.3.1                
 [11] sctransform_0.4.1           utf8_1.2.4                  R6_2.5.1                    lazyeval_0.2.2              uwot_0.2.2                 
 [16] GetoptLong_1.0.5            urlchecker_1.0.1            withr_3.0.0                 gridExtra_2.3               tictoc_1.2.1               
 [21] progressr_0.14.0            cli_3.6.2                   Biobase_2.60.0              Cairo_1.6-2                 spatstat.explore_3.2-7     
 [26] fastDummies_1.7.3           enrichR_3.2                 labeling_0.4.3              spatstat.data_3.0-4         ggridges_0.5.6             
 [31] pbapply_1.7-2               sessioninfo_1.2.2           parallelly_1.37.1           WriteXLS_6.5.0              limma_3.56.2               
 [36] rstudioapi_0.16.0           generics_0.1.3              shape_1.4.6.1               ica_1.0-3                   spatstat.random_3.2-3      
 [41] ggbeeswarm_0.7.2            fansi_1.0.6                 S4Vectors_0.40.2            abind_1.4-5                 lifecycle_1.0.4            
 [46] yaml_2.3.8                  snakecase_0.11.1            SummarizedExperiment_1.30.2 Rtsne_0.17                  paletteer_1.6.0            
 [51] promises_1.3.0              crayon_1.5.2                miniUI_0.1.1.1              lattice_0.21-8              cowplot_1.1.3              
 [56] magick_2.8.3                pillar_1.9.0                knitr_1.46                  GenomicRanges_1.52.1        rjson_0.2.21               
 [61] future.apply_1.11.2         codetools_0.2-19            leiden_0.4.3.1              glue_1.7.0                  remotes_2.5.0              
 [66] vctrs_0.6.5                 png_0.1-8                   spam_2.10-0                 gtable_0.3.5                assertthat_0.2.1           
 [71] rematch2_2.1.2              cachem_1.0.8                xfun_0.43                   S4Arrays_1.0.6              mime_0.12                  
 [76] Rfast_2.1.0                 RcppEigen_0.3.4.0.0         tidygraph_1.3.1             survival_3.5-5              SingleCellExperiment_1.22.0
 [81] pheatmap_1.0.12             iterators_1.0.14            ellipsis_0.3.2              fitdistrplus_1.1-11         ROCR_1.0-11                
 [86] nlme_3.1-162                usethis_2.2.3               RcppAnnoy_0.0.22            GenomeInfoDb_1.36.4         irlba_2.3.5.1              
 [91] vipor_0.4.7                 KernSmooth_2.23-22          colorspace_2.1-0            BiocGenerics_0.48.1         processx_3.8.4             
 [96] ggrastr_1.0.2               tidyselect_1.2.1            compiler_4.3.1              curl_5.2.1                  desc_1.4.3                 
[101] DelayedArray_0.26.7         plotly_4.10.4               scales_1.3.0                lmtest_0.9-40               callr_3.7.6                
[106] rappdirs_0.3.3              digest_0.6.35               goftest_1.2-3               spatstat.utils_3.0-4        presto_1.0.0               
[111] rmarkdown_2.26              XVector_0.40.0              htmltools_0.5.8.1           pkgconfig_2.0.3             MatrixGenerics_1.12.3      
[116] fastmap_1.1.1               rlang_1.1.3                 GlobalOptions_0.1.2         htmlwidgets_1.6.4           shiny_1.8.1.1              
[121] farver_2.1.1                zoo_1.8-12                  jsonlite_1.8.8              RCurl_1.98-1.14             magrittr_2.0.3             
[126] GenomeInfoDbData_1.2.10     dotCall64_1.1-1             munsell_0.5.1               Rcpp_1.0.12                 reticulate_1.36.0          
[131] RcppZiggurat_0.1.6          stringi_1.8.3               zlibbioc_1.46.0             MASS_7.3-60                 pkgbuild_1.4.4             
[136] plyr_1.8.9                  parallel_4.3.1              listenv_0.9.1               deldir_2.0-4                graphlayouts_1.1.1         
[141] splines_4.3.1               tensor_1.5                  hms_1.1.3                   circlize_0.4.16             ps_1.7.6                   
[146] igraph_2.0.3                spatstat.geom_3.2-9         RcppHNSW_0.6.0              pkgload_1.3.4               reshape2_1.4.4             
[151] stats4_4.3.1                evaluate_0.23               RcppParallel_5.1.7          ggprism_1.0.5               tzdb_0.4.0                 
[156] foreach_1.5.2               tweenr_2.0.3                httpuv_1.6.15               RANN_2.6.1                  polyclip_1.10-6            
[161] future_1.33.2               clue_0.3-65                 scattermore_1.2             ggforce_0.4.2               formattable_0.2.1          
[166] janitor_2.2.0               xtable_1.8-4                RSpectra_0.16-1             later_1.3.2                 memoise_2.0.1              
[171] beeswarm_0.4.0              IRanges_2.36.0              cluster_2.1.4               timechange_0.3.0            globals_0.16.3    
enblacar commented 6 months ago

Hi @StefanosVoglis,

Thanks for using my package and for the nice reprex!

Indeed, it seems that the function is labelling the genes that should not be labelled when order_tags_by = "both". I will put it on the ToDo list for the next release. This might be a bit delayed, as I am currently focusing on writing my PhD thesis.

Thanks again for reaching out! Enrique