scDblFinder 1.10.0
See the relevant section of the OSCA book for an example of the recoverDoublets()
function in action on real data.
A toy example is also provided in ?recoverDoublets
.
Consider any two cell states \(C_1\) and \(C_2\) forming a doublet population \(D_{12}\). We will focus on the relative frequency of inter-sample to intra-sample doublets in \(D_{12}\). Given a vector \(\vec p_X\) containing the proportion of cells from each sample in state \(X\), and assuming that doublets form randomly between pairs of samples, the expected proportion of intra-sample doublets in \(D_{12}\) is \(\vec p_{C_1} \cdot \vec p_{C_2}\). Subtracting this from 1 gives us the expected proportion of inter-sample doublets \(q_{D_{12}}\). Similarly, the expected proportion of inter-sample doublets in \(C_1\) is just \(q_{C_1} =1 - \| \vec p_{C_1} \|_2^2\).
Now, let’s consider the observed proportion of events \(r_X\) in each state \(X\) that are known doublets. We have \(r_{D_{12}} = q_{D_{12}}\) as there are no other events in \(D_{12}\) beyond actual doublets. On the other hand, we expect that \(r_{C_1} \ll q_{C_1}\) due to presence of a large majority of non-doublet cells in \(C_1\) (same for \(C_2\)). If we assume that \(q_{D_{12}} \ge q_{C_1}\) and \(q_{C_2}\), the observed proportion \(r_{D_{12}}\) should be larger than \(r_{C_1}\) and \(r_{C_2}\). (The last assumption is not always true but the \(\ll\) should give us enough wiggle room to be robust to violations.)
The above reasoning motivates the use of the proportion of known doublet neighbors as a “doublet score” to identify events that are most likely to be themselves doublets.
recoverDoublets()
computes the proportion of known doublet neighbors for each cell by performing a \(k\)-nearest neighbor search against all other cells in the dataset.
It is then straightforward to calculate the proportion of neighboring cells that are marked as known doublets, representing our estimate of \(r_X\) for each cell.
While the proportions are informative, there comes a time when we need to convert these into explicit doublet calls.
This is achieved with \(\vec S\), the vector of the proportion of cells from each sample across the entire dataset (i.e., samples
).
We assume that all cell states contributing to doublet states have proportion vectors equal to \(\vec S\), such that the expected proportion of doublets that occur between cells from the same sample is \(\| \vec S\|_2^2\).
We then solve
\[ \frac{N_{intra}}{(N_{intra} + N_{inter}} = \| \vec S\|_2^2 \]
for \(N_{intra}\), where \(N_{inter}\) is the number of observed inter-sample doublets. The top \(N_{intra}\) events with the highest scores (and, obviously, are not already inter-sample doublets) are marked as putative intra-sample doublets.
The rate and manner of doublet formation is (mostly) irrelevant as we condition on the number of events in \(D_{12}\). This means that we do not have to make any assumptions about the relative likelihood of doublets forming between pairs of cell types, especially when cell types have different levels of “stickiness” (or worse, stick specifically to certain other cell types). Such convenience is only possible because of the known doublet calls that allow us to focus on the inter- to intra-sample ratio.
The most problematic assumption is that required to obtain \(N_{intra}\) from \(\vec S\). Obtaining a better estimate would require, at least, the knowledge of the two parent states for each doublet population. This can be determined with some simulation-based heuristics but it is likely to be more trouble than it is worth.
In this theoretical framework, we can easily spot a case where our method fails.
If both \(C_1\) and \(C_2\) are unique to a given sample, all events in \(D_{12}\) will be intra-sample doublets.
This means that no events in \(D_{12}\) will ever be detected as inter-sample doublets, which precludes their detection as intra-sample doublets by recoverDoublets
.
The computational remedy is to augment the predictions with simulation-based methods (e.g., scDblFinder()
) while the experimental remedy is to ensure that multiplexed samples include technical or biological replicates.
sessionInfo()
## R version 4.2.0 RC (2022-04-19 r82224)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.4 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] bluster_1.6.0 scDblFinder_1.10.0
## [3] scater_1.24.0 ggplot2_3.3.5
## [5] scran_1.24.0 scuttle_1.6.0
## [7] ensembldb_2.20.0 AnnotationFilter_1.20.0
## [9] GenomicFeatures_1.48.0 AnnotationDbi_1.58.0
## [11] scRNAseq_2.9.2 SingleCellExperiment_1.18.0
## [13] SummarizedExperiment_1.26.0 Biobase_2.56.0
## [15] GenomicRanges_1.48.0 GenomeInfoDb_1.32.0
## [17] IRanges_2.30.0 S4Vectors_0.34.0
## [19] BiocGenerics_0.42.0 MatrixGenerics_1.8.0
## [21] matrixStats_0.62.0 BiocStyle_2.24.0
##
## loaded via a namespace (and not attached):
## [1] AnnotationHub_3.4.0 BiocFileCache_2.4.0
## [3] igraph_1.3.1 lazyeval_0.2.2
## [5] BiocParallel_1.30.0 digest_0.6.29
## [7] htmltools_0.5.2 magick_2.7.3
## [9] viridis_0.6.2 fansi_1.0.3
## [11] magrittr_2.0.3 memoise_2.0.1
## [13] ScaledMatrix_1.4.0 cluster_2.1.3
## [15] limma_3.52.0 Biostrings_2.64.0
## [17] prettyunits_1.1.1 colorspace_2.0-3
## [19] ggrepel_0.9.1 blob_1.2.3
## [21] rappdirs_0.3.3 xfun_0.30
## [23] dplyr_1.0.8 crayon_1.5.1
## [25] RCurl_1.98-1.6 jsonlite_1.8.0
## [27] glue_1.6.2 gtable_0.3.0
## [29] zlibbioc_1.42.0 XVector_0.36.0
## [31] DelayedArray_0.22.0 BiocSingular_1.12.0
## [33] scales_1.2.0 DBI_1.1.2
## [35] edgeR_3.38.0 Rcpp_1.0.8.3
## [37] viridisLite_0.4.0 xtable_1.8-4
## [39] progress_1.2.2 dqrng_0.3.0
## [41] bit_4.0.4 rsvd_1.0.5
## [43] metapod_1.4.0 httr_1.4.2
## [45] ellipsis_0.3.2 farver_2.1.0
## [47] pkgconfig_2.0.3 XML_3.99-0.9
## [49] sass_0.4.1 dbplyr_2.1.1
## [51] locfit_1.5-9.5 utf8_1.2.2
## [53] labeling_0.4.2 tidyselect_1.1.2
## [55] rlang_1.0.2 later_1.3.0
## [57] munsell_0.5.0 BiocVersion_3.15.2
## [59] tools_4.2.0 cachem_1.0.6
## [61] xgboost_1.6.0.1 cli_3.3.0
## [63] generics_0.1.2 RSQLite_2.2.12
## [65] ExperimentHub_2.4.0 evaluate_0.15
## [67] stringr_1.4.0 fastmap_1.1.0
## [69] yaml_2.3.5 knitr_1.38
## [71] bit64_4.0.5 purrr_0.3.4
## [73] KEGGREST_1.36.0 sparseMatrixStats_1.8.0
## [75] mime_0.12 xml2_1.3.3
## [77] biomaRt_2.52.0 compiler_4.2.0
## [79] beeswarm_0.4.0 filelock_1.0.2
## [81] curl_4.3.2 png_0.1-7
## [83] interactiveDisplayBase_1.34.0 tibble_3.1.6
## [85] statmod_1.4.36 bslib_0.3.1
## [87] stringi_1.7.6 highr_0.9
## [89] lattice_0.20-45 ProtGenerics_1.28.0
## [91] Matrix_1.4-1 vctrs_0.4.1
## [93] pillar_1.7.0 lifecycle_1.0.1
## [95] BiocManager_1.30.17 jquerylib_0.1.4
## [97] BiocNeighbors_1.14.0 cowplot_1.1.1
## [99] data.table_1.14.2 bitops_1.0-7
## [101] irlba_2.3.5 httpuv_1.6.5
## [103] rtracklayer_1.56.0 R6_2.5.1
## [105] BiocIO_1.6.0 bookdown_0.26
## [107] promises_1.2.0.1 gridExtra_2.3
## [109] vipor_0.4.5 MASS_7.3-57
## [111] assertthat_0.2.1 rjson_0.2.21
## [113] withr_2.5.0 GenomicAlignments_1.32.0
## [115] Rsamtools_2.12.0 GenomeInfoDbData_1.2.8
## [117] parallel_4.2.0 hms_1.1.1
## [119] grid_4.2.0 beachmat_2.12.0
## [121] rmarkdown_2.14 DelayedMatrixStats_1.18.0
## [123] Rtsne_0.16 shiny_1.7.1
## [125] ggbeeswarm_0.6.0 restfulr_0.0.13