Chapter 1 Introduction
The Bioconductor package SingleR implements an automatic annotation method for single-cell RNA sequencing (scRNA-seq) data (Aran et al. 2019). Given a reference dataset of samples (single-cell or bulk) with known labels, it assigns those labels to new cells from a test dataset based on similarities in their expression profiles. This provides a convenient way of transferring biological knowledge across datasets, allowing users to leverage the domain expertise implicit in the creation of each reference. The most common application of SingleR involves predicting cell type (or “state”, or “kind”) in a new dataset, a process that is facilitated by the availability of curated references and compatibility with user-supplied datasets. In this manner, the burden of manually interpreting clusters and defining marker genes only has to be done once, for the reference dataset, and this knowledge can be propagated to new datasets in an automated manner.
1.2 Method description
SingleR can be considered a robust variant of nearest-neighbors classification, with some tweaks to improve resolution for closely related labels. For each test cell:
- We compute the Spearman correlation between its expression profile and that of each reference sample. The use of Spearman’s correlation provides a measure of robustness to batch effects across datasets. The calculation only uses the union of marker genes identified by pairwise comparisons between labels in the reference data, so as to improve resolution of separation between labels.
- We define the per-label score as a fixed quantile (by default, 0.8) of the correlations across all samples with that label. This accounts for differences in the number of reference samples for each label, which interferes with simpler flavors of nearest neighbor classification; it also avoids penalizing classifications to heterogeneous labels by only requiring a good match to a minority of samples.
- We repeat the score calculation for all labels in the reference dataset. The label with the highest score is used as SingleR’s prediction for this cell.
- We optionally perform a fine-tuning step to improve resolution between closely related labels. The reference dataset is subsetted to only include labels with scores close to the maximum; scores are recomputed using only marker genes for the subset of labels, thus focusing on the most relevant features; and this process is iterated until only one label remains.
1.3 Quick start
# Loading test data. library(TENxPBMCData) new.data <- TENxPBMCData("pbmc4k") # Loading reference data with Ensembl annotations. library(celldex) ref.data <- HumanPrimaryCellAtlasData(ensembl=TRUE) # Performing predictions. library(SingleR) predictions <- SingleR(test=new.data, assay.type.test=1, ref=ref.data, labels=ref.data$label.main) table(predictions$labels)
## ## B_cell CMP DC GMP ## 606 8 1 2 ## Monocyte NK_cell Platelets Pre-B_cell_CD34- ## 1164 217 3 46 ## T_cells ## 2293
And that’s it, really.
1.4 Where to get help
Questions on the general use of SingleR should be posted to the Bioconductor support site. Please send requests for general assistance and advice to the support site rather than to the individual authors. Bug reports or feature requests should be made to the GitHub repository; well-considered suggestions for improvements are always welcome.
R version 4.0.3 (2020-10-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.1 LTS Matrix products: default BLAS: /home/biocbuild/bbs-3.12-bioc/R/lib/libRblas.so LAPACK: /home/biocbuild/bbs-3.12-bioc/R/lib/libRlapack.so locale:  LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C  LC_TIME=en_US.UTF-8 LC_COLLATE=C  LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8  LC_PAPER=en_US.UTF-8 LC_NAME=C  LC_ADDRESS=C LC_TELEPHONE=C  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages:  parallel stats4 stats graphics grDevices utils datasets  methods base other attached packages:  SingleR_1.4.0 ensembldb_2.14.0  AnnotationFilter_1.14.0 GenomicFeatures_1.42.0  AnnotationDbi_1.52.0 celldex_1.0.0  TENxPBMCData_1.8.0 HDF5Array_1.18.0  rhdf5_2.34.0 DelayedArray_0.16.0  Matrix_1.2-18 SingleCellExperiment_1.12.0  SummarizedExperiment_1.20.0 Biobase_2.50.0  GenomicRanges_1.42.0 GenomeInfoDb_1.26.0  IRanges_2.24.0 S4Vectors_0.28.0  BiocGenerics_0.36.0 MatrixGenerics_1.2.0  matrixStats_0.57.0 BiocStyle_2.18.0  rebook_1.0.0 loaded via a namespace (and not attached):  ProtGenerics_1.22.0 bitops_1.0-6  bit64_4.0.5 progress_1.2.2  httr_1.4.2 tools_4.0.3  irlba_2.3.3 R6_2.5.0  lazyeval_0.2.2 DBI_1.1.0  rhdf5filters_1.2.0 prettyunits_1.1.1  tidyselect_1.1.0 processx_3.4.4  bit_4.0.4 curl_4.3  compiler_4.0.3 graph_1.68.0  BiocNeighbors_1.8.0 xml2_1.3.2  rtracklayer_1.50.0 bookdown_0.21  askpass_1.1 callr_3.5.1  rappdirs_0.3.1 Rsamtools_2.6.0  stringr_1.4.0 digest_0.6.27  rmarkdown_2.5 XVector_0.30.0  pkgconfig_2.0.3 htmltools_0.5.0  sparseMatrixStats_1.2.0 dbplyr_1.4.4  fastmap_1.0.1 rlang_0.4.8  RSQLite_2.2.1 shiny_1.5.0  DelayedMatrixStats_1.12.0 generics_0.1.0  BiocParallel_1.24.0 dplyr_1.0.2  BiocSingular_1.6.0 RCurl_1.98-1.2  magrittr_1.5 GenomeInfoDbData_1.2.4  Rcpp_1.0.5 Rhdf5lib_1.12.0  lifecycle_0.2.0 stringi_1.5.3  yaml_2.2.1 zlibbioc_1.36.0  BiocFileCache_1.14.0 AnnotationHub_2.22.0  grid_4.0.3 blob_1.2.1  promises_1.1.1 ExperimentHub_1.16.0  crayon_1.3.4 lattice_0.20-41  beachmat_2.6.0 Biostrings_2.58.0  hms_0.5.3 CodeDepends_0.6.5  knitr_1.30 ps_1.4.0  pillar_1.4.6 codetools_0.2-16  biomaRt_2.46.0 XML_3.99-0.5  glue_1.4.2 BiocVersion_3.12.0  evaluate_0.14 BiocManager_1.30.10  vctrs_0.3.4 httpuv_1.5.4  openssl_1.4.3 purrr_0.3.4  assertthat_0.2.1 xfun_0.19  rsvd_1.0.3 mime_0.9  xtable_1.8-4 later_126.96.36.199  tibble_3.0.4 GenomicAlignments_1.26.0  memoise_1.1.0 ellipsis_0.3.1  interactiveDisplayBase_1.28.0
Aran, D., A. P. Looney, L. Liu, E. Wu, V. Fong, A. Hsu, S. Chak, et al. 2019. “Reference-based analysis of lung single-cell sequencing reveals a transitional profibrotic macrophage.” Nat. Immunol. 20 (2): 163–72.
Mabbott, Neil A., J. K. Baillie, Helen Brown, Tom C. Freeman, and David A. Hume. 2013. “An expression atlas of human primary cells: Inference of gene function from coexpression networks.” BMC Genomics 14. https://doi.org/10.1186/1471-2164-14-632.
Zheng, G. X., J. M. Terry, P. Belgrader, P. Ryvkin, Z. W. Bent, R. Wilson, S. B. Ziraldo, et al. 2017. “Massively parallel digital transcriptional profiling of single cells.” Nat Commun 8 (January): 14049.