Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: PseudobulkExpression ignores user-specified scale.factor argument #9756

Open
anncfs opened this issue Mar 18, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@anncfs
Copy link

anncfs commented Mar 18, 2025

Issue Description

PseudobulkExpression (and AggregateExpression) do not pass user-specified scale.factor to NormalizeData

Reproducing Code Example

library(Seurat)

# create two pseudobulk expression Seurat objects using "groups" metadata annotation of pbmc_small
pb_1e6 <- PseudobulkExpression(pbmc_small, return.seurat = T, method = "aggregate", group.by = "groups", normalization.method = "RC", scale.factor = 1e6)
pb_default <- PseudobulkExpression(pbmc_small, return.seurat = T, method = "aggregate", group.by = "groups", normalization.method = "RC")

# default scale.factor is used for RC normalisation regardless of whether this is specified above
colSums(pb_1e6[["RNA"]]$data)
#   g1    g2 
# 10000 10000 
colSums(pb_default[["RNA"]]$data)
#   g1    g2 
# 10000 10000 

# you need to rerun Normalize Data directly to use a different scale.factor
colSums(NormalizeData(pb_1e6, normalization.method = "RC", scale.factor = 1e6))
#   g1    g2 
# 1e+06 1e+06 

Error Message

Additional Comments

I believe this is due to the scale.factor argument specified when using either AggregateExpression or PseudobulkExpression not being passed to NormalizeData in lines 1546-1550 of seurat/R/utilities.R

Session Info

R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20.0.0
Running under: macOS Ventura 13.6.7

Matrix products: default
BLAS/LAPACK: /Users/ab1511/miniconda3/envs/singlecell/lib/libopenblas.0.dylib;  LAPACK version 3.12.0

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

time zone: Europe/London
tzcode source: system (macOS)

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

other attached packages:
[1] Seurat_5.2.1       SeuratObject_5.0.2 sp_2.2-0          

loaded via a namespace (and not attached):
  [1] deldir_2.0-4           pbapply_1.7-2          gridExtra_2.3         
  [4] rlang_1.1.5            magrittr_2.0.3         RcppAnnoy_0.0.22      
  [7] matrixStats_1.5.0      ggridges_0.5.6         compiler_4.4.2        
 [10] spatstat.geom_3.3-5    png_0.1-8              vctrs_0.6.5           
 [13] reshape2_1.4.4         stringr_1.5.1          pkgconfig_2.0.3       
 [16] fastmap_1.2.0          promises_1.3.2         purrr_1.0.4           
 [19] jsonlite_1.9.0         goftest_1.2-3          later_1.4.1           
 [22] spatstat.utils_3.1-2   irlba_2.3.5.1          parallel_4.4.2        
 [25] cluster_2.1.8          R6_2.6.1               ica_1.0-3             
 [28] stringi_1.8.4          RColorBrewer_1.1-3     spatstat.data_3.1-4   
 [31] reticulate_1.40.0      parallelly_1.42.0      spatstat.univar_3.1-1 
 [34] lmtest_0.9-40          scattermore_1.2        Rcpp_1.0.14           
 [37] tensor_1.5             future.apply_1.11.3    zoo_1.8-12            
 [40] sctransform_0.4.1      httpuv_1.6.15          Matrix_1.7-2          
 [43] splines_4.4.2          igraph_2.1.4           tidyselect_1.2.1      
 [46] abind_1.4-8            codetools_0.2-20       spatstat.random_3.3-2 
 [49] miniUI_0.1.1.1         spatstat.explore_3.3-4 listenv_0.9.1         
 [52] lattice_0.22-6         tibble_3.2.1           plyr_1.8.9            
 [55] shiny_1.10.0           ROCR_1.0-11            Rtsne_0.17            
 [58] future_1.34.0          fastDummies_1.7.5      survival_3.8-3        
 [61] polyclip_1.10-7        fitdistrplus_1.2-2     pillar_1.10.1         
 [64] KernSmooth_2.23-26     plotly_4.10.4          generics_0.1.3        
 [67] RcppHNSW_0.6.0         ggplot2_3.5.1          munsell_0.5.1         
 [70] scales_1.3.0           globals_0.16.3         xtable_1.8-4          
 [73] glue_1.8.0             lazyeval_0.2.2         tools_4.4.2           
 [76] data.table_1.16.4      RSpectra_0.16-2        RANN_2.6.2            
 [79] dotCall64_1.2          cowplot_1.1.3          grid_4.4.2            
 [82] tidyr_1.3.1            colorspace_2.1-1       nlme_3.1-167          
 [85] patchwork_1.3.0        cli_3.6.4              spatstat.sparse_3.1-0 
 [88] spam_2.11-1            viridisLite_0.4.2      dplyr_1.1.4           
 [91] uwot_0.2.2             gtable_0.3.6           digest_0.6.37         
 [94] progressr_0.15.1       ggrepel_0.9.6          htmlwidgets_1.6.4     
 [97] farver_2.1.2           htmltools_0.5.8.1      lifecycle_1.0.4       
[100] httr_1.4.7             mime_0.12              MASS_7.3-64
@anncfs anncfs added the bug Something isn't working label Mar 18, 2025
@anncfs anncfs changed the title BUG: <insert-descriptive-title> BUG: PseudobulkExpression ignores user-specified scale.factor argument Mar 18, 2025
@mhkowalski
Copy link
Contributor

Can confirm that this a bug, thank you for reporting this! We will have a fix out as soon as we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants