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

Error when projecting reference dataset with on-disc data matrix: "Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 't': Argument 'x' must be of type logical, integer or numeric, not 'list'" #9659

Open
sbamopoulos opened this issue Jan 31, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@sbamopoulos
Copy link

Hello,

after lengthy debugging I noticed that there is an issue when projecting a reference dataset onto a query dataset if the reference dataset "data" matrix is not stored in memory, but instead is stored on disk using the BPcells package. Here is a sample code:

library(Seurat)
library(SeuratObject)
library(BPCells)

query.obj <- readRDS("path1.rds")
ref.obj <- readRDS("path2.rds")

tanc <- FindTransferAnchors(reference = ref.obj, reference.assay = "RNA", reference.reduction = "rpca_integrated",
                            query = query.obj, query.assay = "RNA", scale = T, project.query = F,
                            normalization.method = "LogNormalize", dims = 1:30, verbose = T)

query.obj <- MapQuery(anchorset = tanc, query = query.obj, reference = ref.obj, refdata = "annotation_ref", 
                   reference.reduction = "rpca_integrated", new.reduction.name = "pcaref")

This produces this non-informative error:

Projecting cell embeddings
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 't': Argument 'x' must be of type logical, integer or numeric, not 'list'

However, if I convert the "data" matrix to an in memory matrix, as per your tutorial:

ref.obj[["RNA"]]$data <- as(object = ref.obj[["RNA"]]$data, Class = "dgCMatrix")

The code runs through without an error:

Projecting cell embeddings
Finding neighborhoods
Finding anchors
	Found 2346 anchors
Finding neighborhoods
Finding anchors
	Found 1874 anchors
Finding neighborhoods
Finding anchors
	Found 2081 anchors
Finding neighborhoods
Finding anchors
	Found 2674 anchors
Finding neighborhoods
Finding anchors
	Found 1497 anchors
Finding neighborhoods
Finding anchors
	Found 1582 anchors
Finding neighborhoods
Finding anchors
	Found 1815 anchors
Finding neighborhoods
Finding anchors
	Found 1043 anchors
Finding neighborhoods
Finding anchors
	Found 2100 anchors
Finding neighborhoods
Finding anchors
	Found 1221 anchors
Finding neighborhoods
Finding anchors
	Found 2547 anchors
sessionInfo()
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default


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

time zone: Europe/Berlin
tzcode source: internal

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

other attached packages:
 [1] dplyr_1.1.4        tidyr_1.3.1        writexl_1.5.1      export_0.3.0       dittoSeq_1.14.3    ggplot2_3.5.1      BPCells_0.1.0     
 [8] Seurat_5.2.1       SeuratObject_5.0.2 sp_2.1-4          

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22            splines_4.3.3               later_1.4.1                 bitops_1.0-9                tibble_3.2.1               
  [6] polyclip_1.10-7             fastDummies_1.7.4           lifecycle_1.0.4             globals_0.16.3              lattice_0.22-6             
 [11] MASS_7.3-60.0.1             backports_1.5.0             magrittr_2.0.3              openxlsx_4.2.7.1            plotly_4.10.4              
 [16] rmarkdown_2.29              httpuv_1.6.15               sctransform_0.4.1           spam_2.11-0                 zip_2.3.1                  
 [21] askpass_1.2.1               spatstat.sparse_3.1-0       reticulate_1.40.0           cowplot_1.1.3               pbapply_1.7-2              
 [26] RColorBrewer_1.1-3          pkgload_1.4.0               abind_1.4-8                 zlibbioc_1.48.2             Rtsne_0.17                 
 [31] GenomicRanges_1.54.1        purrr_1.0.2                 BiocGenerics_0.48.1         RCurl_1.98-1.16             rgl_1.3.17                 
 [36] gdtools_0.4.1               GenomeInfoDbData_1.2.11     IRanges_2.36.0              S4Vectors_0.40.2            ggrepel_0.9.6              
 [41] irlba_2.3.5.1               listenv_0.9.1               spatstat.utils_3.1-2        pheatmap_1.0.12             goftest_1.2-3              
 [46] RSpectra_0.16-2             spatstat.random_3.3-2       fitdistrplus_1.2-2          parallelly_1.41.0           codetools_0.2-20           
 [51] DelayedArray_0.28.0         xml2_1.3.6                  tidyselect_1.2.1            farver_2.1.2                base64enc_0.1-3            
 [56] matrixStats_1.5.0           stats4_4.3.3                spatstat.explore_3.3-4      jsonlite_1.8.9              progressr_0.15.1           
 [61] ggridges_0.5.6              survival_3.8-3              systemfonts_1.2.0           tools_4.3.3                 ragg_1.3.3                 
 [66] ica_1.0-3                   Rcpp_1.0.14                 glue_1.8.0                  gridExtra_2.3               SparseArray_1.2.4          
 [71] xfun_0.50                   MatrixGenerics_1.14.0       GenomeInfoDb_1.38.8         withr_3.0.2                 fastmap_1.2.0              
 [76] openssl_2.3.1               digest_0.6.37               R6_2.5.1                    mime_0.12                   textshaping_0.4.1          
 [81] colorspace_2.1-1            scattermore_1.2             tensor_1.5                  spatstat.data_3.1-4         generics_0.1.3             
 [86] fontLiberation_0.1.0        data.table_1.16.4           httr_1.4.7                  htmlwidgets_1.6.4           S4Arrays_1.2.1             
 [91] uwot_0.2.2                  pkgconfig_2.0.3             gtable_0.3.6                lmtest_0.9-40               SingleCellExperiment_1.24.0
 [96] XVector_0.42.0              htmltools_0.5.8.1           fontBitstreamVera_0.1.1     dotCall64_1.2               rvg_0.3.4                  
[101] scales_1.3.0                Biobase_2.62.0              png_0.1-8                   spatstat.univar_3.1-1       knitr_1.49                 
[106] rstudioapi_0.17.1           reshape2_1.4.4              uuid_1.2-1                  nlme_3.1-166                zoo_1.8-12                 
[111] flextable_0.9.7             stringr_1.5.1               KernSmooth_2.23-26          parallel_4.3.3              miniUI_0.1.1.1             
[116] pillar_1.10.1               grid_4.3.3                  vctrs_0.6.5                 RANN_2.6.2                  promises_1.3.2             
[121] xtable_1.8-4                cluster_2.1.8               evaluate_1.0.3              cli_3.6.3                   compiler_4.3.3             
[126] rlang_1.1.5                 crayon_1.5.3                future.apply_1.11.3         labeling_0.4.3              plyr_1.8.9                 
[131] stringi_1.8.4               viridisLite_0.4.2           deldir_2.0-4                munsell_0.5.1               lazyeval_0.2.2             
[136] spatstat.geom_3.3-5         fontquiver_0.2.1            Matrix_1.6-5                RcppHNSW_0.6.0              patchwork_1.3.0            
[141] future_1.34.0               devEMF_4.5                  stargazer_5.2.3             shiny_1.10.0                SummarizedExperiment_1.32.0
[146] ROCR_1.0-11                 igraph_2.1.3                broom_1.0.7                 officer_0.6.7              


Best
Stefan

@sbamopoulos sbamopoulos added the bug Something isn't working label Jan 31, 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