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_FeaturePlot | The legend titles are not displayed anymore #68

Closed frac2738 closed 3 months ago

frac2738 commented 3 months ago

It has been a while that do_FeaturePlot has a strange behaviour. The legend title is not displayed anymore.

library(SCpubr)
options("SCpubr.ColorPaletteEnds" = TRUE)

exp_Integrated <- readRDS(...)
do_FeaturePlot(exp_Integrated, c("nFeature_RNA","nCount_RNA"), legend.position = "right", 
                            use_viridis = TRUE, viridis.palette = "D",viridis.direction = -1)

The code above returns a figure without the legend title image

This make difficult to know which one is which. Of course I know that the left is "nFeature_RNA" and the right is "nCount_RNA", but this can be problematic when the figures are shared.

So far a workaround is to add the title to the single plots and then combine them together

u1 <- do_FeaturePlot(exp_Integrated, "nFeature_RNA", use_viridis = TRUE, viridis.palette = "D",viridis.direction = -1) + ggtitle("nFeature")
u2 <- do_FeaturePlot(exp_Integrated, "nCount_RNA", use_viridis = TRUE, viridis.palette = "D",viridis.direction = -1)+ggtitle("nCount")
u1|u2

I tried to re-install SCpubr multiple times, but nothing has changed. I don't think this is an intended behaviour...is that correct?

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

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/libf77blas.so.3.10.3 
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK version 3.9.0

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

time zone: Europe/Paris
tzcode source: system (glibc)

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

other attached packages:
[1] viridis_0.6.5     viridisLite_0.4.2 SCpubr_2.0.2      dittoSeq_1.14.3   ggplot2_3.5.1     scR_0.9.8.7      

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3          rstudioapi_0.16.0           jsonlite_1.8.8              shape_1.4.6.1               magrittr_2.0.3                      spatstat.utils_3.0-4        farver_2.1.2               
  [8] ragg_1.3.1                  zlibbioc_1.48.2             GlobalOptions_0.1.2         vctrs_0.6.5                 ROCR_1.0-11                     spatstat.explore_3.2-7      RCurl_1.98-1.14            
 [15] forcats_1.0.0               S4Arrays_1.2.1              htmltools_0.5.8.1           SparseArray_1.2.4           sctransform_0.4.1           parallelly_1.37.1           KernSmooth_2.23-22         
 [22] htmlwidgets_1.6.4           ica_1.0-3                   plyr_1.8.9                  plotly_4.10.4               zoo_1.8-12                  igraph_2.0.3                mime_0.12                  
 [29] lifecycle_1.0.4             pkgconfig_2.0.3             Matrix_1.6-5                R6_2.5.1                    fastmap_1.2.0               GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
 [36] fitdistrplus_1.1-11         future_1.33.2               shiny_1.8.1.1               digest_0.6.36               colorspace_2.1-0            patchwork_1.2.0             S4Vectors_0.40.2           
 [43] Seurat_5.0.3                tensor_1.5                  RSpectra_0.16-1             irlba_2.3.5.1               textshaping_0.3.7           GenomicRanges_1.54.1        labeling_0.4.3             
 [50] progressr_0.14.0            fansi_1.0.6                 spatstat.sparse_3.0-3       httr_1.4.7                  polyclip_1.10-6             abind_1.4-5                 compiler_4.3.1             
 [57] withr_3.0.0                 fastDummies_1.7.3           MASS_7.3-60.0.1             DelayedArray_0.28.0         wesanderson_0.3.7           tools_4.3.1                 lmtest_0.9-40              
 [64] zip_2.3.1                   httpuv_1.6.15               future.apply_1.11.2         goftest_1.2-3               glue_1.7.0                  nlme_3.1-164                promises_1.3.0             
 [71] grid_4.3.1                  Rtsne_0.17                  cluster_2.1.6               reshape2_1.4.4              generics_0.1.3              gtable_0.3.5                spatstat.data_3.0-4        
 [78] tidyr_1.3.1                 data.table_1.15.4           XVector_0.42.0              sp_2.1-4                    utf8_1.2.4                  BiocGenerics_0.48.1         spatstat.geom_3.2-9        
 [85] RcppAnnoy_0.0.22            ggrepel_0.9.5               RANN_2.6.1                  pillar_1.9.0                stringr_1.5.1               spam_2.10-0                 RcppHNSW_0.6.0             
 [92] later_1.3.2                 circlize_0.4.16             splines_4.3.1               dplyr_1.1.4                 lattice_0.22-6              survival_3.5-8              deldir_2.0-4               
 [99] tidyselect_1.2.1            SingleCellExperiment_1.24.0 miniUI_0.1.1.1              pbapply_1.7-2               gridExtra_2.3               IRanges_2.36.0              SummarizedExperiment_1.32.0
[106] scattermore_1.2             stats4_4.3.1                Biobase_2.62.0              matrixStats_1.3.0           pheatmap_1.0.12             stringi_1.8.4               lazyeval_0.2.2             
[113] codetools_0.2-20            tibble_3.2.1                cli_3.6.2                   uwot_0.2.2                  systemfonts_1.0.6           xtable_1.8-4                reticulate_1.36.1          
[120] munsell_0.5.1               Rcpp_1.0.12                 GenomeInfoDb_1.38.8         globals_0.16.3              spatstat.random_3.2-3       png_0.1-8                   parallel_4.3.1             
[127] assertthat_0.2.1            dotCall64_1.1-1             bitops_1.0-7                listenv_0.9.1               scales_1.3.0                ggridges_0.5.6              crayon_1.5.2               
[134] SeuratObject_5.0.2          leiden_0.4.3.1              openxlsx_4.2.5.2            purrr_1.0.2                 rlang_1.1.4                 cowplot_1.1.3              
enblacar commented 3 months ago

Hi @frac2738,

Thank you for bringing this up! Let me have a quick look and get back to you!

Enrique

enblacar commented 3 months ago

Hi @frac2738,

This seems to be an odd bug that somehow it is not showing up in my environment. I might need some time to further delve into it and see what is breaking on another environment that reproduces the bug.

Before that, could I ask you to quickly download the latest commit from GitHub and check again if legend titles are still missing?

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

Thanks a lot! Will keep you updated on this. Enrique

frac2738 commented 3 months ago

Hi @enblacar, thanks for taking the time to looking into this bug.

I upgrade the version I had to the last commit (SCpubr_2.0.2.9000), and the behaviour did not change

exp_Integrated <- readRDS("int_B-only.Rds") 
b_markers <- read.csv("B_markers.txt")
do_FeaturePlot(exp_Integrated, features = b_markers$IG_genes, legend.position = "right") 

image

enblacar commented 3 months ago

Hi @frac2738,

Interesting. Even if I download the CRAN version, it works fine within my system environment. I will have to delve into this with some more time. Thanks again for bringing this up and for the help!

Enrique

enblacar commented 3 months ago

Hi @frac2738,

I have committed a hotfix that probably solves the issue. To be honest, this was a rather hard to reproduce bug, as it only happened in some devices while in others not (also tested in other colleague's RStudio sessions).

Could you please give it a go downloading SCpubr with the latest commit and let me know if this fixed your issue? If so, it will roll out in the next update of SCpubr.

devtools::install_github("enblacar/SCpubr" ref = "e9eace273bec3e6518f82a091378bc2e380e5489")

Looking forward to the answer! Enrique

frac2738 commented 3 months ago

I will do more testing in the coming days, but it seems to work now.

> do_FeaturePlot(exp_Integrated,c("CD8A","CD3E"),
+                order = TRUE, viridis.palette = "D",use_viridis = TRUE,
+                viridis.direction = -1, legend.position = "right", legend.length = 8)

image

Thank you for fixing it this quickly!

enblacar commented 3 months ago

Hi @frac2738,

Great news! Happy that it worked.

I will close this issue now. Please feel free to open a new issue if you encounter anything else. Given how obscure this error was to my checks, I could foresee other similar ones popping up in other functions. If you encounter them, I would really appreciate if you let me know!

Best, Enrique