Error in SingleR when using scRNAseq dataset : number of labels must be equal to number of cells
0
0
Entering edit mode
2.3 years ago
Candice • 0

Hi, I am trying to load the scRNAseq package WuKidneyData() to perform the SingleR function to annotate my single-cell data pbmc.1k.sce

library(scRNAseq)
WuKidney.data <- WuKidneyData(ensembl = FALSE)

Due the lack of logcounts in assay(), I have to create one on my own:

counts <- assay(WuKidney.data, "counts")
libsizes <- colSums(counts)
size.factors <- libsizes/mean(libsizes)
logcounts(WuKidney.data) <- log2(t(t(counts)/size.factors) + 1)

In addition, I need to capitalize the gene ID:

rownames(WuKidney.data) <- toupper(rownames(WuKidney.data)) 

However, when I run 'SingleR()', I ran into an error message:

prediction <- SingleR(test=pbmc.1k.sce, assay.type.test=1, 
                               ref=WuKidney.data, labels=WuKidney.data$label.main)

Error in (function (ref, labels, genes = "de", sd.thresh = 1, de.method = "classic",  : 
      number of labels must be equal to number of cells

Please let me know how could I fix it. Thank you!

Session info:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] scRNAseq_2.4.0              DT_0.20                     R2HTML_2.3.2               
 [4] rjson_0.2.21                scales_1.1.1                Matrix_1.4-0               
 [7] SeuratObject_4.0.4          Seurat_4.0.1                forcats_0.5.1              
[10] stringr_1.4.0               dplyr_1.0.7                 purrr_0.3.4                
[13] readr_2.1.1                 tidyr_1.1.4                 tibble_3.1.6               
[16] tidyverse_1.3.1             pheatmap_1.0.12             celldex_1.0.0              
[19] SingleR_1.4.1               cellassign_0.99.21          tensorflow_2.7.0           
[22] DropletUtils_1.10.3         scran_1.18.7                scater_1.18.6              
[25] ggplot2_3.3.5               SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0
[28] Biobase_2.50.0              GenomicRanges_1.42.0        GenomeInfoDb_1.26.7        
[31] IRanges_2.24.1              S4Vectors_0.28.1            BiocGenerics_0.36.1        
[34] MatrixGenerics_1.2.1        matrixStats_0.61.0         

loaded via a namespace (and not attached):
  [1] rappdirs_0.3.3                rtracklayer_1.50.0            scattermore_0.7              
  [4] R.methodsS3_1.8.1             bit64_4.0.5                   irlba_2.3.5                  
  [7] DelayedArray_0.16.3           R.utils_2.11.0                data.table_1.14.2            
 [10] rpart_4.1-15                  AnnotationFilter_1.14.0       RCurl_1.98-1.5               
 [13] generics_0.1.1                GenomicFeatures_1.42.3        cowplot_1.1.1                
 [16] RSQLite_2.2.9                 RANN_2.6.1                    future_1.23.0                
 [19] bit_4.0.4                     tzdb_0.2.0                    spatstat.data_2.1-2          
 [22] xml2_1.3.3                    lubridate_1.8.0               httpuv_1.6.5                 
 [25] assertthat_0.2.1              viridis_0.6.2                 xfun_0.29                    
 [28] jquerylib_0.1.4               hms_1.1.1                     promises_1.2.0.1             
 [31] progress_1.2.2                fansi_1.0.2                   dbplyr_2.1.1                 
 [34] readxl_1.3.1                  igraph_1.2.6                  DBI_1.1.2                    
 [37] htmlwidgets_1.5.4             spatstat.geom_2.3-1           ellipsis_0.3.2               
 [40] crosstalk_1.2.0               RSpectra_0.16-0               backports_1.4.1              
 [43] biomaRt_2.46.3                deldir_1.0-6                  sparseMatrixStats_1.2.1      
 [46] vctrs_0.3.8                   ensembldb_2.14.1              here_1.0.1                   
 [49] ROCR_1.0-11                   abind_1.4-5                   cachem_1.0.6                 
 [52] withr_2.4.3                   vroom_1.5.7                   sctransform_0.3.2            
 [55] GenomicAlignments_1.26.0      prettyunits_1.1.1             goftest_1.2-3                
 [58] cluster_2.1.2                 ExperimentHub_1.16.1          lazyeval_0.2.2               
 [61] crayon_1.4.2                  edgeR_3.32.1                  pkgconfig_2.0.3              
 [64] labeling_0.4.2                ProtGenerics_1.22.0           nlme_3.1-152                 
 [67] vipor_0.4.5                   rlang_0.4.12                  globals_0.14.0               
 [70] lifecycle_1.0.1               miniUI_0.1.1.1                BiocFileCache_1.14.0         
 [73] modelr_0.1.8                  rsvd_1.0.5                    AnnotationHub_2.22.1         
 [76] cellranger_1.1.0              rprojroot_2.0.2               polyclip_1.10-0              
 [79] lmtest_0.9-39                 Rhdf5lib_1.12.1               zoo_1.8-9                    
 [82] reprex_2.0.1                  base64enc_0.1-3               beeswarm_0.4.0               
 [85] whisker_0.4                   ggridges_0.5.3                png_0.1-7                    
 [88] viridisLite_0.4.0             bitops_1.0-7                  R.oo_1.24.0                  
 [91] KernSmooth_2.23-20            rhdf5filters_1.2.1            Biostrings_2.58.0            
 [94] blob_1.2.2                    DelayedMatrixStats_1.12.3     parallelly_1.30.0            
 [97] beachmat_2.6.4                memoise_2.0.1                 magrittr_2.0.1               
[100] plyr_1.8.6                    ica_1.0-2                     zlibbioc_1.36.0              
[103] compiler_4.0.2                dqrng_0.3.0                   tinytex_0.36                 
[106] RColorBrewer_1.1-2            fitdistrplus_1.1-6            Rsamtools_2.6.0              
[109] cli_3.1.0                     XVector_0.30.0                listenv_0.8.0                
[112] patchwork_1.1.1               pbapply_1.5-0                 MASS_7.3-55                  
[115] mgcv_1.8-38                   tidyselect_1.1.1              stringi_1.7.6                
[118] yaml_2.2.1                    askpass_1.1                   BiocSingular_1.6.0           
[121] locfit_1.5-9.4                ggrepel_0.9.1                 grid_4.0.2                   
[124] sass_0.4.0                    tools_4.0.2                   future.apply_1.8.1           
[127] rstudioapi_0.13               bluster_1.0.0                 gridExtra_2.3                
[130] farver_2.1.0                  Rtsne_0.15                    digest_0.6.29                
[133] BiocManager_1.30.16           shiny_1.7.1                   Rcpp_1.0.8                   
[136] broom_0.7.11                  scuttle_1.0.4                 BiocVersion_3.12.0           
[139] later_1.3.0                   RcppAnnoy_0.0.19              httr_1.4.2                   
[142] AnnotationDbi_1.52.0          colorspace_2.0-2              XML_3.99-0.8                 
[145] rvest_1.0.2                   fs_1.5.2                      tensor_1.5                   
[148] reticulate_1.23               splines_4.0.2                 uwot_0.1.11                  
[151] statmod_1.4.36                spatstat.utils_2.3-0          plotly_4.10.0                
[154] xtable_1.8-4                  jsonlite_1.7.2                R6_2.5.1                     
[157] pillar_1.6.4                  htmltools_0.5.2               mime_0.12                    
[160] glue_1.6.0                    fastmap_1.1.0                 BiocParallel_1.24.1          
[163] BiocNeighbors_1.8.2           interactiveDisplayBase_1.28.0 codetools_0.2-18             
[166] utf8_1.2.2                    bslib_0.3.1                   lattice_0.20-45              
[169] spatstat.sparse_2.1-0         curl_4.3.2                    ggbeeswarm_0.6.0             
[172] leiden_0.3.9                  tfruns_1.5.0                  openssl_1.4.6                
[175] survival_3.2-13               limma_3.46.0                  munsell_0.5.0                
[178] rhdf5_2.34.0                  GenomeInfoDbData_1.2.4        HDF5Array_1.18.1             
[181] haven_2.4.3                   reshape2_1.4.4                gtable_0.3.0                 
[184] spatstat.core_2.3-2  
scRNAseq SingleCellExperiment SingleR R • 1.2k views
ADD COMMENT
0
Entering edit mode

It appears the problem is caused by the fact that there is no WuKidney.data$label.main info in the dataset.

ADD REPLY

Login before adding your answer.

Traffic: 2274 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