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: AggregateExpression creates wrong metadata if a column in group.by has only one value. #9757

Open
dimitrios-pm opened this issue Mar 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@dimitrios-pm
Copy link

Issue Description

The AggregateExpression function behaves unexpectedly when passing arguments with only one value.
pseudo_data<- AggregateExpression(ifnb, assays = "RNA", return.seurat = TRUE, group.by = c("orig.ident","GROUP", "seurat_annotations"))
Which gives:
"The following grouping variables have 1 value and will be ignored: GROUP"
It creates a seurat object but that objects metadata are wrong.

I would expect the correct behaviour to be that if it would be ignored then the resulting object should have identical metadata as if that value is not there.

Reproducing Code Example

library(Seurat)
library(SeuratData)

ifnb <- LoadData("ifnb")

ifnb$GROUP <- "group1"
pseudo_data<- AggregateExpression(ifnb, assays = "RNA", return.seurat = TRUE, group.by = c("orig.ident", "seurat_annotations"))
pseudo_data2<- AggregateExpression(ifnb, assays = "RNA", return.seurat = TRUE, group.by = c("orig.ident","GROUP", "seurat_annotations"))

Error Message

Additional Comments

No response

Session Info

> sessionInfo()
R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_Denmark.utf8  LC_CTYPE=English_Denmark.utf8   
[3] LC_MONETARY=English_Denmark.utf8 LC_NUMERIC=C                    
[5] LC_TIME=English_Denmark.utf8    

time zone: Europe/Copenhagen
tzcode source: internal

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

other attached packages:
[1] Seurat_5.2.1          SeuratObject_5.0.2    sp_2.2-0             
[4] ifnb.SeuratData_3.1.0 cbmc.SeuratData_3.1.4 SeuratData_0.2.2.9002

loaded via a namespace (and not attached):
  [1] deldir_2.0-4           pbapply_1.7-2         
  [3] gridExtra_2.3          remotes_2.5.0         
  [5] rlang_1.1.4            magrittr_2.0.3        
  [7] RcppAnnoy_0.0.22       spatstat.geom_3.3-5   
  [9] matrixStats_1.4.1      ggridges_0.5.6        
 [11] compiler_4.4.3         png_0.1-8             
 [13] callr_3.7.6            vctrs_0.6.5           
 [15] reshape2_1.4.4         stringr_1.5.1         
 [17] crayon_1.5.3           pkgconfig_2.0.3       
 [19] fastmap_1.2.0          promises_1.3.2        
 [21] ps_1.9.0               purrr_1.0.2           
 [23] jsonlite_1.8.8         goftest_1.2-3         
 [25] later_1.4.1            spatstat.utils_3.1-3  
 [27] irlba_2.3.5.1          parallel_4.4.3        
 [29] cluster_2.1.8          R6_2.6.1              
 [31] ica_1.0-3              stringi_1.8.4         
 [33] RColorBrewer_1.1-3     spatstat.data_3.1-6   
 [35] reticulate_1.41.0.1    parallelly_1.42.0     
 [37] spatstat.univar_3.1-2  lmtest_0.9-40         
 [39] scattermore_1.2        Rcpp_1.0.13-1         
 [41] tensor_1.5             future.apply_1.11.3   
 [43] zoo_1.8-13             sctransform_0.4.1     
 [45] httpuv_1.6.15          Matrix_1.7-2          
 [47] splines_4.4.3          igraph_2.1.3          
 [49] tidyselect_1.2.1       rstudioapi_0.17.1     
 [51] abind_1.4-8            spatstat.random_3.3-2 
 [53] codetools_0.2-20       miniUI_0.1.1.1        
 [55] spatstat.explore_3.3-4 curl_6.2.0            
 [57] processx_3.8.6         listenv_0.9.1         
 [59] pkgbuild_1.4.6         lattice_0.22-6        
 [61] tibble_3.2.1           plyr_1.8.9            
 [63] shiny_1.10.0           ROCR_1.0-11           
 [65] Rtsne_0.17             future_1.34.0         
 [67] fastDummies_1.7.5      desc_1.4.3            
 [69] survival_3.8-3         polyclip_1.10-7       
 [71] fitdistrplus_1.2-2     pillar_1.10.1         
 [73] KernSmooth_2.23-26     plotly_4.10.4         
 [75] generics_0.1.3         RcppHNSW_0.6.0        
 [77] ggplot2_3.5.1          munsell_0.5.1         
 [79] scales_1.3.0           globals_0.16.3        
 [81] xtable_1.8-4           glue_1.7.0            
 [83] lazyeval_0.2.2         tools_4.4.3           
 [85] data.table_1.15.4      RSpectra_0.16-2       
 [87] RANN_2.6.2             dotCall64_1.2         
 [89] cowplot_1.1.3          grid_4.4.3            
 [91] tidyr_1.3.1            colorspace_2.1-1      
 [93] nlme_3.1-167           patchwork_1.3.0       
 [95] cli_3.6.3              rappdirs_0.3.3        
 [97] spatstat.sparse_3.1-0  spam_2.11-1           
 [99] viridisLite_0.4.2      dplyr_1.1.4           
[101] uwot_0.2.3             gtable_0.3.6          
[103] digest_0.6.37          progressr_0.15.1      
[105] ggrepel_0.9.6          htmlwidgets_1.6.4     
[107] farver_2.1.2           htmltools_0.5.8.1     
[109] lifecycle_1.0.4        httr_1.4.7            
[111] mime_0.12              MASS_7.3-64
@dimitrios-pm dimitrios-pm added the bug Something isn't working label Mar 18, 2025
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

1 participant