alanocallaghan / scater

Clone of the Bioconductor repository for the scater package.
https://bioconductor.org/packages/devel/bioc/html/scater.html
95 stars 40 forks source link

can plotUMAP offer a order parameter #172

Closed shangguandong1996 closed 2 years ago

shangguandong1996 commented 2 years ago

Hi, Dear Developer. I am wondering whehter plotUMAP or plotReducedDim can offer can option which can plot point according to the expression value like order parameter in FeaturePlot of Seurat. Because sometimes, my gene express in only some cells in one clusters. And it will be buried by others cell.

Best wishes

Guandong Shang

LTLA commented 2 years ago

Makes sense to me. I used to just scramble the column order of the input SCE but I suppose that can be pretty expensive if you're not using DelayedArrays.

shangguandong1996 commented 2 years ago

Thanks Aaron, For the scramble the column order of input SCE, you mean like below code?

example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)

example_sce <- runPCA(example_sce, ncomponents=5)

plotUMAP(example_sce[, order(logcounts(example_sce["Gene_0001", ]))],
         colour_by = "Gene_0001")
alanocallaghan commented 2 years ago

Sounds good, thanks for raising the issue

shangguandong1996 commented 2 years ago

Hi I find it seems that the order_by parameter not work

library(scater)

example_sce <- mockSCE()
example_sce <- logNormCounts(example_sce)
example_sce <- runPCA(example_sce)
example_sce <- runUMAP(example_sce)
plotUMAP(example_sce,
         colour_by = "Gene_0001")

图片

If I add order_by parameter, there is only some cells left

plotUMAP(example_sce,
         colour_by = "Gene_0001",
         order_by = "Gene_0001")

图片

> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Stream 8

Matrix products: default
BLAS:   /opt/sysoft/R-4.2.0/lib64/R/lib/libRblas.so
LAPACK: /opt/sysoft/R-4.2.0/lib64/R/lib/libRlapack.so

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

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

other attached packages:
 [1] scater_1.25.6               ggplot2_3.3.6              
 [3] scuttle_1.6.2               SingleCellExperiment_1.18.0
 [5] SummarizedExperiment_1.26.1 Biobase_2.56.0             
 [7] GenomicRanges_1.48.0        GenomeInfoDb_1.32.2        
 [9] IRanges_2.30.0              S4Vectors_0.34.0           
[11] BiocGenerics_0.42.0         MatrixGenerics_1.8.0       
[13] matrixStats_0.62.0         

loaded via a namespace (and not attached):
 [1] ggrepel_0.9.1             Rcpp_1.0.9                rsvd_1.0.5               
 [4] lattice_0.20-45           FNN_1.1.3.1               digest_0.6.29            
 [7] assertthat_0.2.1          utf8_1.2.2                RSpectra_0.16-1          
[10] R6_2.5.1                  pillar_1.7.0              sparseMatrixStats_1.8.0  
[13] zlibbioc_1.42.0           rlang_1.0.3               rstudioapi_0.13          
[16] irlba_2.3.5               Matrix_1.4-1              labeling_0.4.2           
[19] BiocNeighbors_1.14.0      BiocParallel_1.30.2       RCurl_1.98-1.6           
[22] munsell_0.5.0             uwot_0.1.11               beachmat_2.12.0          
[25] DelayedArray_0.22.0       compiler_4.2.0            vipor_0.4.5              
[28] BiocSingular_1.12.0       pkgconfig_2.0.3           ggbeeswarm_0.6.0         
[31] tidyselect_1.1.2          tibble_3.1.7              gridExtra_2.3            
[34] GenomeInfoDbData_1.2.8    fansi_1.0.3               viridisLite_0.4.0        
[37] crayon_1.5.1              dplyr_1.0.9               withr_2.5.0              
[40] bitops_1.0-7              grid_4.2.0                gtable_0.3.0             
[43] lifecycle_1.0.1           DBI_1.1.2                 magrittr_2.0.3           
[46] scales_1.2.0              ScaledMatrix_1.4.0        cli_3.3.0                
[49] farver_2.1.0              XVector_0.36.0            viridis_0.6.2            
[52] DelayedMatrixStats_1.18.0 ellipsis_0.3.2            generics_0.1.2           
[55] vctrs_0.4.1               cowplot_1.1.1             tools_4.2.0              
[58] glue_1.6.2                beeswarm_0.4.0            purrr_0.3.4              
[61] parallel_4.2.0            colorspace_2.0-3
alanocallaghan commented 2 years ago

Ah yeah my bad, left out an order when refactoring some code

shangguandong1996 commented 2 years ago

Thanks :), it work well now