satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

DotPlot inverting colors #8650

Closed dfermin closed 5 months ago

dfermin commented 7 months ago

Hello. I don't know if this is a bug or not but I was hoping to get sum clarification on this.

I have found a weird behavior in Dotplot. In my data I know that "Gene1" is highly expressed in the cells derived from treated mice vs the healthy controls ("VG1_TRT" vs "VG1_HC"). When I execute the this code:

DotPlot(ssData, features="EPHA7", group.by="subclass.l1", split.by="sampletype", dot.scale=10)  + 
theme(panel.grid.major.y=element_line(size=0.1), panel.background=element_rect(fill="seashell"))

I get the plot on the left. Since I didn't specify any colors in the DotPlot() function it should color the highest expression in blue as stated in the documentation. But it does the opposite in the case of VG1_TRT.

If I execute this code:

DotPlot(ssData, features="EPHA7", group.by="subclass.l1", split.by="sampletype", dot.scale=10, cols="Spectral")  + 
theme(panel.grid.major.y=element_line(size=0.1))

I get the DotPlot on the right correctly showing that VG1_TRT having the highest expression. As far as I can tell, if you do not specify a value for the cols argument in DotPlot the "blue is high" coloring scheme is not necessarily followed by the function as documented.

EPHA7_dotplots2

Obviously I can always ensure the correct coloring is performed by using the col="Spectral" argument to my DotPlot commands but I wasn't sure if this was a bug or not so I posted it here hoping for some suggestions.

Thanks, Damian

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.9 (Ootpa)

Matrix products: default
BLAS/LAPACK: /opt/OpenBLAS/lib/libopenblas_skylakexp-r0.3.18.so

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

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

other attached packages:
[1] RColorBrewer_1.1-3 ggpubr_0.6.0       ggplot2_3.4.2      dplyr_1.1.2        sp_1.6-0           SeuratObject_4.1.1 Seurat_4.1.1       nvimcom_0.9-115

loaded via a namespace (and not attached):
  [1] Rtsne_0.16            colorspace_2.1-0      ggsignif_0.6.4        deldir_1.0-6          ellipsis_0.3.2        ggridges_0.5.3        spatstat.data_2.2-0   farver_2.1.1          leiden_0.4.3
 [10] listenv_0.8.0         ggrepel_0.9.3         fansi_1.0.5           codetools_0.2-18      splines_4.1.2         polyclip_1.10-0       jsonlite_1.8.5        broom_0.8.0           ica_1.0-2
 [19] cluster_2.1.3         png_0.1-7             rgeos_0.6-2           uwot_0.1.14           shiny_1.7.1           sctransform_0.3.4     spatstat.sparse_2.1-1 compiler_4.1.2        httr_1.4.4
 [28] backports_1.4.1       Matrix_1.5-4          fastmap_1.1.0         lazyeval_0.2.2        cli_3.6.1             later_1.3.0           htmltools_0.5.2       tools_4.1.2           igraph_1.3.1
 [37] gtable_0.3.1          glue_1.6.2            RANN_2.6.1            reshape2_1.4.4        Rcpp_1.0.10           scattermore_0.8       carData_3.0-5         vctrs_0.6.4           nlme_3.1-157
 [46] progressr_0.11.0      lmtest_0.9-40         spatstat.random_2.2-0 stringr_1.5.0         globals_0.16.1        mime_0.12             miniUI_0.1.1.1        lifecycle_1.0.3       irlba_2.3.5
 [55] rstatix_0.7.2         goftest_1.2-3         future_1.28.0         MASS_7.3-57           zoo_1.8-11            scales_1.2.1          spatstat.core_2.4-2   promises_1.2.0.1      spatstat.utils_2.3-0
 [64] parallel_4.1.2        reticulate_1.26       pbapply_1.5-0         gridExtra_2.3         rpart_4.1.16          stringi_1.7.6         rlang_1.1.0           pkgconfig_2.0.3       matrixStats_0.62.0
 [73] lattice_0.20-45       ROCR_1.0-11           purrr_1.0.1           tensor_1.5            labeling_0.4.3        patchwork_1.1.2       htmlwidgets_1.5.4     cowplot_1.1.1         tidyselect_1.2.0
 [82] parallelly_1.32.1     RcppAnnoy_0.0.19      plyr_1.8.7            magrittr_2.0.3        R6_2.5.1              generics_0.1.3        DBI_1.1.3             pillar_1.9.0          withr_2.5.2
 [91] mgcv_1.8-40           fitdistrplus_1.1-8    survival_3.3-1        abind_1.4-5           tibble_3.2.1          future.apply_1.9.1    crayon_1.5.1          car_3.1-2             KernSmooth_2.23-20
[100] utf8_1.2.4            spatstat.geom_2.4-0   plotly_4.10.0         grid_4.1.2            data.table_1.14.2     digest_0.6.29         xtable_1.8-4          tidyr_1.3.0           httpuv_1.6.5
[109] munsell_0.5.0         viridisLite_0.4.2
zskylarli commented 6 months ago

Hi - have you tried DotPlot(ssData, features="EPHA7", group.by="subclass.l1", split.by="sampletype", dot.scale=10) without the additional ggplot arguments? Just wondering since we don't expect this behavior and have not seen similar bugs on our side, so this could be some sort of visualization conflict with the additional themes that you have specified. If not, please keep us updated.

liuyu988 commented 1 month ago

i also see the same problem