seurat icon indicating copy to clipboard operation
seurat copied to clipboard

Featureplot not generated right plot when using raster=T

Open shanshenbing opened this issue 6 months ago • 2 comments

I used Featureplot to get the visualization of my srobj. I found cells were not sorted when setting raster=T. The sercond and third plots seem to be the same.

#when raster=F
FeaturePlot(object = srobj,
            features =c('STAT3'),
            order = T,
            min.cutoff = 'q10',max.cutoff = 'q90',raster = F)

image

#when raster=T
FeaturePlot(object = srobj,
            features =c('STAT3'),
            order = T,
            min.cutoff = 'q10',max.cutoff = 'q90',raster = T)

image

#when raster=T and not sort cells.
FeaturePlot(object = srobj,
            features =c('STAT3'),
            order = F,
            min.cutoff = 'q10',max.cutoff = 'q90',raster = T)

image

I have try to sort cell manually as https://github.com/satijalab/seurat/issues/5762. But this is not useful. I have tried in r.4.1.3 and r.4.3.2, and got similar results. I checked code of FeaturePlot function and the only difference is this:

plot <- if (isTRUE(x = raster)) {
    plot + geom_scattermore(mapping = aes_string(x = dims[1], 
      y = dims[2], color = paste0("`", col.by, "`"), shape = shape.by, 
      alpha = alpha.by), pointsize = pt.size, pixels = raster.dpi)
  }
  else {
    plot + geom_point(mapping = aes_string(x = dims[1], 
      y = dims[2], color = paste0("`", col.by, "`"), shape = shape.by, 
      alpha = alpha.by), size = pt.size)
  }

But I am not sure this codes will or not cause the bugs. Now, I use the following code to generate rastered plots.

library(ggrastr)
p1 <- FeaturePlot(object = srobj,
            features =c('STAT3'),
            order = T, min.cutoff = 'q10',max.cutoff = 'q90',raster = F)
rasterize(p1, layers='Point', dpi=300)

session info:

sessionInfo() R version 4.3.2 (2023-10-31) Platform: x86_64-conda-linux-gnu (64-bit) Running under: Ubuntu 22.04.3 LTS

Matrix products: default BLAS/LAPACK: /cluster/home/shanshenbing/soft/anaconda3/envs/r.4.3.2/lib/libopenblasp-r0.3.24.so; LAPACK version 3.11.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: Etc/UTC tzcode source: system (glibc)

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

other attached packages: [1] ggrastr_1.0.2 Seurat_4.4.0 SeuratObject_5.0.0 sp_2.1-1
[5] ggpubr_0.6.0 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.0
[9] dplyr_1.1.3 purrr_1.0.2 readr_2.1.4 tidyr_1.3.0
[13] tibble_3.2.1 tidyverse_2.0.0 ggthemes_4.2.4 ggsci_3.0.0
[17] ggplot2_3.4.4

loaded via a namespace (and not attached): [1] RColorBrewer_1.1-3 rstudioapi_0.15.0 jsonlite_1.8.7
[4] magrittr_2.0.3 ggbeeswarm_0.7.2 spatstat.utils_3.0-4
[7] farver_2.1.1 vctrs_0.6.4 ROCR_1.0-11
[10] Cairo_1.6-2 spatstat.explore_3.2-5 rstatix_0.7.2
[13] htmltools_0.5.7 broom_1.0.5 sctransform_0.4.1
[16] parallelly_1.36.0 KernSmooth_2.23-22 htmlwidgets_1.6.2
[19] ica_1.0-3 plyr_1.8.9 plotly_4.10.3
[22] zoo_1.8-12 igraph_1.5.1 mime_0.12
[25] lifecycle_1.0.3 pkgconfig_2.0.3 Matrix_1.6-1.1
[28] R6_2.5.1 fastmap_1.1.1 fitdistrplus_1.1-11
[31] future_1.33.0 shiny_1.7.5.1 digest_0.6.33
[34] colorspace_2.1-0 patchwork_1.1.3 tensor_1.5
[37] irlba_2.3.5.1 labeling_0.4.3 progressr_0.14.0
[40] fansi_1.0.5 spatstat.sparse_3.0-3 timechange_0.2.0
[43] httr_1.4.7 polyclip_1.10-6 abind_1.4-5
[46] compiler_4.3.2 withr_2.5.2 backports_1.4.1
[49] carData_3.0-5 qs_0.25.5 ggsignif_0.6.4
[52] MASS_7.3-60 tools_4.3.2 vipor_0.4.7
[55] lmtest_0.9-40 beeswarm_0.4.0 httpuv_1.6.12
[58] future.apply_1.11.0 goftest_1.2-3 glue_1.6.2
[61] nlme_3.1-163 promises_1.2.1 grid_4.3.2
[64] Rtsne_0.16 cluster_2.1.4 reshape2_1.4.4
[67] generics_0.1.3 gtable_0.3.4 spatstat.data_3.0-3
[70] tzdb_0.4.0 data.table_1.14.8 RApiSerialize_0.1.2
[73] hms_1.1.3 stringfish_0.15.7 car_3.1-2
[76] utf8_1.2.4 spatstat.geom_3.2-7 RcppAnnoy_0.0.21
[79] ggrepel_0.9.4 RANN_2.6.1 pillar_1.9.0
[82] spam_2.10-0 later_1.3.1 splines_4.3.2
[85] lattice_0.22-5 survival_3.5-7 deldir_1.0-9
[88] tidyselect_1.2.0 miniUI_0.1.1.1 pbapply_1.7-2
[91] gridExtra_2.3 scattermore_1.2 matrixStats_1.0.0
[94] pheatmap_1.0.12 stringi_1.7.12 lazyeval_0.2.2
[97] codetools_0.2-19 cli_3.6.1 uwot_0.1.16
[100] RcppParallel_5.1.6 xtable_1.8-4 reticulate_1.34.0
[103] munsell_0.5.0 Rcpp_1.0.11 globals_0.16.2
[106] spatstat.random_3.2-1 png_0.1-8 parallel_4.3.2
[109] ellipsis_0.3.2 dotCall64_1.1-0 listenv_0.9.0
[112] viridisLite_0.4.2 scales_1.2.1 ggridges_0.5.4
[115] leiden_0.4.3 rlang_1.1.2 cowplot_1.1.1

shanshenbing avatar Dec 27 '23 02:12 shanshenbing