satijalab / seurat

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

FeaturePlot arguments only applying to last plot with use of split.by function #9425

Open sadhnarao opened 3 hours ago

sadhnarao commented 3 hours ago

I would like to plot gene expression in UMAPs, split by disease state. But when I use split.by the arguments 'pt.size' and 'order' only apply to the last plot

p1<-Seurat::FeaturePlot(seuratObj, features = c("GAPDH") , cols = c("grey", "red"),order = TRUE, pt.size = 1.5, split.by = "meta_disease")

image

I reviewed prior questions and solutions for this (#235) but the comment thread closes by stating that the latest version of Seurat has addressed this with the order = TRUE argument.

Does anyone have a solution for this that will allow 'order' and 'pt.size' arguments to apply to all graphs?

samuel-marsh commented 3 hours ago

Hi,

Not member of dev team but hopefully can be helpful. So I think what might be happening from looking at the plots is that due to the number of cells in the first split panel it is being rasterized and the second plot is not. If you set raster = FALSE that should solve the issue.

If I use pbmc dataset you can see that modifying those parameters modifies both of the plots in the split, but this can get messy with rasterization depending on cell number. Reproducible example below showing both plots are modified by changing parameters when rasterization isn't an issue. This issue with rasterization is also resolved in custom version of FeaturePlot from my package scCustomize (among other changes to the default vignette here)

Best, Sam

suppressMessages(library(Seurat))

pbmc <- pbmc3k.SeuratData::pbmc3k.final
pbmc <- suppressMessages(UpdateSeuratObject(pbmc))
#> Warning: Assay RNA changing from Assay to Assay
#> Warning: Graph RNA_nn changing from Graph to Graph
#> Warning: Graph RNA_snn changing from Graph to Graph
#> Warning: DimReduc pca changing from DimReduc to DimReduc
#> Warning: DimReduc umap changing from DimReduc to DimReduc
#> Warning: Adding a command log without an assay associated with it
#> Adding a command log without an assay associated with it

pbmc$sample_id <- sample(c("sample1", "sample2"), size = ncol(pbmc),
                         replace = TRUE)

FeaturePlot(pbmc, features = "ACTB", split.by = "sample_id", order = T, pt.size = 2)

FeaturePlot(pbmc, features = "ACTB", split.by = "sample_id", order = F, pt.size = 2)

Created on 2024-10-24 with reprex v2.1.1

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.0 (2024-04-24) #> os macOS Monterey 12.7.5 #> system x86_64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/New_York #> date 2024-10-24 #> pandoc 3.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-8 2024-09-12 [1] CRAN (R 4.4.1) #> cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.0) #> cluster 2.1.6 2023-12-01 [1] CRAN (R 4.4.0) #> codetools 0.2-20 2024-03-31 [1] CRAN (R 4.4.0) #> colorspace 2.1-1 2024-07-26 [1] CRAN (R 4.4.0) #> cowplot 1.1.3 2024-01-22 [1] CRAN (R 4.4.0) #> curl 5.2.3 2024-09-20 [1] CRAN (R 4.4.1) #> data.table 1.16.2 2024-10-10 [1] CRAN (R 4.4.1) #> deldir 2.0-4 2024-02-28 [1] CRAN (R 4.4.0) #> digest 0.6.37 2024-08-19 [1] CRAN (R 4.4.1) #> dotCall64 1.2 2024-10-04 [1] CRAN (R 4.4.1) #> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.4.0) #> evaluate 1.0.1 2024-10-10 [1] CRAN (R 4.4.1) #> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.4.0) #> farver 2.1.2 2024-05-13 [1] CRAN (R 4.4.0) #> fastDummies 1.7.4 2024-08-16 [1] CRAN (R 4.4.1) #> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.0) #> fitdistrplus 1.2-1 2024-07-12 [1] CRAN (R 4.4.0) #> fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.0) #> future 1.34.0 2024-07-29 [1] CRAN (R 4.4.0) #> future.apply 1.11.2 2024-03-28 [1] CRAN (R 4.4.0) #> generics 0.1.3 2022-07-05 [1] CRAN (R 4.4.0) #> ggplot2 3.5.1 2024-04-23 [1] CRAN (R 4.4.0) #> ggrepel 0.9.6 2024-09-07 [1] CRAN (R 4.4.1) #> ggridges 0.5.6 2024-01-23 [1] CRAN (R 4.4.0) #> globals 0.16.3 2024-03-08 [1] CRAN (R 4.4.0) #> glue 1.8.0 2024-09-30 [1] CRAN (R 4.4.1) #> goftest 1.2-3 2021-10-07 [1] CRAN (R 4.4.0) #> gridExtra 2.3 2017-09-09 [1] CRAN (R 4.4.0) #> gtable 0.3.5 2024-04-22 [1] CRAN (R 4.4.0) #> highr 0.11 2024-05-26 [1] CRAN (R 4.4.0) #> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0) #> htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.4.0) #> httpuv 1.6.15 2024-03-26 [1] CRAN (R 4.4.0) #> httr 1.4.7 2023-08-15 [1] CRAN (R 4.4.0) #> ica 1.0-3 2022-07-08 [1] CRAN (R 4.4.0) #> igraph 2.1.1 2024-10-19 [1] CRAN (R 4.4.1) #> irlba 2.3.5.1 2022-10-03 [1] CRAN (R 4.4.0) #> jsonlite 1.8.9 2024-09-20 [1] CRAN (R 4.4.1) #> KernSmooth 2.23-24 2024-05-17 [1] CRAN (R 4.4.0) #> knitr 1.48 2024-07-07 [1] CRAN (R 4.4.0) #> labeling 0.4.3 2023-08-29 [1] CRAN (R 4.4.0) #> later 1.3.2 2023-12-06 [1] CRAN (R 4.4.0) #> lattice 0.22-6 2024-03-20 [1] CRAN (R 4.4.0) #> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.4.0) #> leiden 0.4.3.1 2023-11-17 [1] CRAN (R 4.4.0) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0) #> listenv 0.9.1 2024-01-29 [1] CRAN (R 4.4.0) #> lmtest 0.9-40 2022-03-21 [1] CRAN (R 4.4.0) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.0) #> MASS 7.3-61 2024-06-13 [1] CRAN (R 4.4.0) #> Matrix 1.7-1 2024-10-18 [1] CRAN (R 4.4.1) #> matrixStats 1.4.1 2024-09-08 [1] CRAN (R 4.4.1) #> mime 0.12 2021-09-28 [1] CRAN (R 4.4.0) #> miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.4.0) #> munsell 0.5.1 2024-04-01 [1] CRAN (R 4.4.0) #> nlme 3.1-166 2024-08-14 [1] CRAN (R 4.4.1) #> parallelly 1.38.0 2024-07-27 [1] CRAN (R 4.4.0) #> patchwork 1.3.0 2024-09-16 [1] CRAN (R 4.4.1) #> pbapply 1.7-2 2023-06-27 [1] CRAN (R 4.4.0) #> pbmc3k.SeuratData 3.1.4 2024-05-01 [1] local #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.4.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.4.0) #> plotly 4.10.4 2024-01-13 [1] CRAN (R 4.4.0) #> plyr 1.8.9 2023-10-02 [1] CRAN (R 4.4.0) #> png 0.1-8 2022-11-29 [1] CRAN (R 4.4.0) #> polyclip 1.10-7 2024-07-23 [1] CRAN (R 4.4.0) #> progressr 0.14.0 2023-08-10 [1] CRAN (R 4.4.0) #> promises 1.3.0 2024-04-05 [1] CRAN (R 4.4.0) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.4.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.0) #> RANN 2.6.2 2024-08-25 [1] CRAN (R 4.4.1) #> RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.4.0) #> Rcpp 1.0.13 2024-07-17 [1] CRAN (R 4.4.0) #> RcppAnnoy 0.0.22 2024-01-23 [1] CRAN (R 4.4.0) #> RcppHNSW 0.6.0 2024-02-04 [1] CRAN (R 4.4.0) #> reprex 2.1.1 2024-07-06 [1] CRAN (R 4.4.0) #> reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.4.0) #> reticulate 1.39.0 2024-09-05 [1] CRAN (R 4.4.1) #> rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.0) #> rmarkdown 2.28 2024-08-17 [1] CRAN (R 4.4.1) #> ROCR 1.0-11 2020-05-02 [1] CRAN (R 4.4.0) #> RSpectra 0.16-2 2024-07-18 [1] CRAN (R 4.4.0) #> rstudioapi 0.17.1 2024-10-22 [1] CRAN (R 4.4.1) #> Rtsne 0.17 2023-12-07 [1] CRAN (R 4.4.0) #> scales 1.3.0 2023-11-28 [1] CRAN (R 4.4.0) #> scattermore 1.2 2023-06-12 [1] CRAN (R 4.4.0) #> sctransform 0.4.1 2023-10-19 [1] CRAN (R 4.4.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.0) #> Seurat * 5.1.0 2024-05-10 [1] CRAN (R 4.4.0) #> SeuratObject * 5.0.2 2024-05-08 [1] CRAN (R 4.4.0) #> shiny 1.9.1 2024-08-01 [1] CRAN (R 4.4.0) #> sp * 2.1-4 2024-04-30 [1] CRAN (R 4.4.0) #> spam 2.11-0 2024-10-03 [1] CRAN (R 4.4.1) #> spatstat.data 3.1-2 2024-06-21 [1] CRAN (R 4.4.0) #> spatstat.explore 3.3-3 2024-10-22 [1] CRAN (R 4.4.1) #> spatstat.geom 3.3-3 2024-09-18 [1] CRAN (R 4.4.1) #> spatstat.random 3.3-2 2024-09-18 [1] CRAN (R 4.4.1) #> spatstat.sparse 3.1-0 2024-06-21 [1] CRAN (R 4.4.0) #> spatstat.univar 3.0-1 2024-09-05 [1] CRAN (R 4.4.1) #> spatstat.utils 3.1-0 2024-08-17 [1] CRAN (R 4.4.1) #> stringi 1.8.4 2024-05-06 [1] CRAN (R 4.4.0) #> stringr 1.5.1 2023-11-14 [1] CRAN (R 4.4.0) #> survival 3.7-0 2024-06-05 [1] CRAN (R 4.4.0) #> tensor 1.5 2012-05-05 [1] CRAN (R 4.4.0) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.4.0) #> tidyr 1.3.1 2024-01-24 [1] CRAN (R 4.4.0) #> tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.4.0) #> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.4.0) #> uwot 0.2.2 2024-04-21 [1] CRAN (R 4.4.0) #> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.0) #> viridisLite 0.4.2 2023-05-02 [1] CRAN (R 4.4.0) #> withr 3.0.1 2024-07-31 [1] CRAN (R 4.4.0) #> xfun 0.48 2024-10-03 [1] CRAN (R 4.4.1) #> xml2 1.3.6 2023-12-04 [1] CRAN (R 4.4.0) #> xtable 1.8-4 2019-04-21 [1] CRAN (R 4.4.0) #> yaml 2.3.10 2024-07-26 [1] CRAN (R 4.4.0) #> zoo 1.8-12 2023-04-13 [1] CRAN (R 4.4.0) #> #> [1] /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```