SingleR error with multiple references
0
0
Entering edit mode
carlo • 0
@a6c2c2e7
Last seen 17 months ago
Italy

Since the recent upgrade to 'BiocVersion' 3.16.0, upgrading 'SingleR' to 2.0.0, I was not able to successfully run 'SingleR' with multiple references as I was used to do up to few weeks ago. I went through all the vignettes and manual pages I was able to retrieve on the matter but without solving the problem.

Hereafter I report a slightly modified version of the 'SingleR' example from the Help, by introducing a second reference to mimic the multiple references analysis:


# Mocking up data with log-normalized expression values:
ref1 <- .mockRefData() # 1st reference
ref2 <- .mockRefData() # 2nd reference
test <- .mockTestData(ref1)

ref1 <- scuttle::logNormCounts(ref1)
ref2 <- scuttle::logNormCounts(ref2)
test <- scuttle::logNormCounts(test)

ref <- list(ref1,ref2) # list of multiple references

ref1.labels <- ref1$label # ref1 labels
ref.labels <- list(ref1$label,ref2$label) # multiple references' labels


# Running the classification with different options:
pred.a <- SingleR(test, ref1, labels=ref1.labels) # works OK

pred.b <- SingleR(test, ref, labels=ref.labels) # DOES NOT work, giving the above mentioned error and warning messsages.


Error in results[[i]] : subscript out of bounds
In addition: Warning messages:
1: In combineRecomputedResults(results, test = test, trained = trained,  :
  entries of 'trained' differ in the universe of available markers
2: In combineRecomputedResults(results, test = test, trained = trained,  :
 entries of 'trained' differ in the universe of available markers

By tracing back the error I get:


> traceback()
3: combineRecomputedResults(results, test = test, trained = trained, 
       check.missing = FALSE, quantile = quantile)
2: classifySingleR(test, trained, quantile = quantile, fine.tune = fine.tune, 
       tune.thresh = tune.thresh, prune = prune, check.missing = FALSE, 
       num.threads = num.threads, BPPARAM = BPPARAM)
1: SingleR(test, ref, labels = ref.labels)

After running 'debugonce(SingleR)', within the 'classifySingleR' function chunk, 'results' is empty and as a consequence the final 'combineRecomputedResults' function leads to the error and warning messages (I report only the crucial lines here):

> debugonce(SingleR)
> pred.b <- SingleR(test, ref, labels=ref.labels) # does not work
debugging in: SingleR(test, ref, labels = ref.labels)

...

Browse[2]> s
debugging in: classifySingleR(test, trained, quantile = quantile, fine.tune = fine.tune, 
    tune.thresh = tune.thresh, prune = prune, check.missing = FALSE, 
    num.threads = num.threads, BPPARAM = BPPARAM)

...

Browse[3]> 
debug: results <- lapply(trained, FUN = .classify_internals, test = test, 
    quantile = quantile, fine.tune = fine.tune, tune.thresh = tune.thresh, 
    prune = prune, num.threads = num.threads)

## 'results' is empty here, thus leading to the failure of the next function:

Browse[3]> 
debug: combineRecomputedResults(results, test = test, trained = trained, 
    check.missing = FALSE, quantile = quantile)
Browse[3]> 
Error in results[[i]] : subscript out of bounds
In addition: Warning messages:
1: In combineRecomputedResults(results, test = test, trained = trained,  :
  entries of 'trained' differ in the universe of available markers
2: In combineRecomputedResults(results, test = test, trained = trained,  :
  entries of 'trained' differ in the universe of available markers



> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /home/carlo/R/R-4.2.0/lib/libRblas.so
LAPACK: /home/carlo/R/R-4.2.0/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=it_IT.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=it_IT.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=it_IT.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
 [1] datasets  stats4    grid      parallel  grDevices compiler  stats     graphics  utils     methods  
[11] base     

other attached packages:
  [1] scAnnotatR_0.99.7           devtools_2.4.5              usethis_2.1.6              
  [4] ggalluvial_0.12.3           CellChat_1.5.0              circlize_0.4.15            
  [7] NMF_0.24.0                  rngtools_1.5.2              pkgmaker_0.32.2            
 [10] registry_0.5-1              parallelly_1.32.1           BiocParallel_1.32.1        
 [13] heatmap3_1.1.9              ComplexHeatmap_2.14.0       superheat_0.1.0            
 [16] MAST_1.24.0                 ggraph_2.1.0                glmGamPoi_1.10.0           
 [19] harmony_0.1.1               Rcpp_1.0.9                  biomaRt_2.54.0             
 [22] patchwork_1.1.2             ggpubr_0.5.0                HGNChelper_0.8.1           
 [25] dbplyr_2.2.1                forcats_0.5.2               stringr_1.4.1              
 [28] dplyr_1.0.10                purrr_0.3.5                 readr_2.1.3                
 [31] tidyr_1.2.1                 tibble_3.1.8                tidyverse_1.3.2            
 [34] mclust_6.0.0                monocle3_1.2.9              ggrastr_1.0.1              
 [37] HDF5Array_1.26.0            rhdf5_2.42.0                Matrix.utils_0.9.8         
 [40] batchelor_1.14.0            lme4_1.1-31                 DelayedMatrixStats_1.20.0  
 [43] DelayedArray_0.24.0         infercnv_1.14.0             leiden_0.4.3               
 [46] scater_1.26.1               scran_1.26.0                scuttle_1.8.0              
 [49] scRNAseq_2.12.0             SingleCellExperiment_1.20.0 celldex_1.8.0              
 [52] SingleR_2.0.0               SummarizedExperiment_1.28.0 GenomicRanges_1.50.1       
 [55] GenomeInfoDb_1.34.3         MatrixGenerics_1.10.0       matrixStats_0.62.0         
 [58] SeuratWrappers_0.3.0        SeuratObject_4.1.3          Seurat_4.2.1               
 [61] edgeR_3.40.0                installr_0.23.4             uwot_0.1.14                
 [64] statmod_1.4.37              AnnotationDbi_1.60.0        IRanges_2.32.0             
 [67] S4Vectors_0.36.0            Polychrome_1.5.1            randomcoloR_1.1.0.1        
 [70] GSA_1.03.2                  tm_0.7-9                    NLP_0.2-1                  
 [73] limma_3.54.0                Rmisc_1.5.1                 plotly_4.10.1              
 [76] Hmisc_4.7-1                 ggplot2_3.4.0               Formula_1.2-4              
 [79] survival_3.4-0              lattice_0.20-45             corrgram_1.14              
 [82] corrplot_0.92               umap_0.2.9.0                clusterProfiler_4.6.0      
 [85] tictoc_1.1                  gridBase_0.4-7              eulerr_6.1.1               
 [88] networkD3_0.4               plotrix_3.8-2               ff_4.0.7                   
 [91] bit_4.0.5                   car_3.1-1                   carData_3.0-5              
 [94] smoothie_1.0-3              vcd_1.4-10                  locfit_1.5-9.6             
 [97] Rtsne_0.16                  tsne_0.1-3.1                sp_1.5-1                   
[100] fields_14.1                 viridis_0.6.2               viridisLite_0.4.1          
[103] spam_2.9-1                  doParallel_1.0.17           iterators_1.0.14           
[106] foreach_1.5.2               beeswarm_0.4.0              tgp_2.4-20                 
[109] beanplot_1.3.1              fpc_2.2-9                   dbscan_1.1-11              
[112] vioplot_0.3.7               zoo_1.8-11                  sm_2.2-5.7.1               
[115] MASS_7.3-58.1               ellipse_0.4.3               cluster_2.1.4              
[118] scales_1.2.1                multtest_2.54.0             Biobase_2.58.0             
[121] BiocGenerics_0.44.0         metap_1.8                   magrittr_2.0.3             
[124] colorspace_2.0-3            igraph_1.3.5                RColorBrewer_1.1-3         
[127] plyr_1.8.8                  Matrix_1.5-3                conflicted_1.1.0           
[130] BiocManager_1.30.19

Is there anything I am missing?

Thanks in advance for any advice, Carlo

SingleR • 765 views
ADD COMMENT
0
Entering edit mode

[103] spam_2.9-1 doParallel_1.0.17 iterators_1.0.14
[106] foreach_1.5.2 beeswarm_0.4.0 tgp_2.4-20
[109] beanplot_1.3.1 fpc_2.2-9 dbscan_1.1-11
[112] vioplot_0.3.7 zoo_1.8-11 sm_2.2-5.7.1
[115] MASS_7.3-58.1 ellipse_0.4.3 cluster_2.1.4
[118] scales_1.2.1 multtest_2.54.0 Biobase_2.58.0
[121] BiocGenerics_0.44.0 metap_1.8 magrittr_2.0.3
[124] colorspace_2.0-3 igraph_1.3.5 RColorBrewer_1.1-3
[127] plyr_1.8.8 Matrix_1.5-3 conflicted_1.1.0
[130] BiocManager_1.30.19

Read more: https://support.bioconductor.org/ snow rider 3d

ADD REPLY

Login before adding your answer.

Traffic: 553 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6