Contents

1 Introduction

Analyses in single-cell RNAseq are typically limited to a relatively small (e.g. one or two thousands) set of features that are most informative; these are often the genes with a higher expression (and hence more chances of being quantified). In contrast, single-cell ATACseq (scATACseq) data is considerably more sparse, with most reads being spread across hundreds of thousands of regions. In this context, selecting a subset of genes is highly ineffective, and therefore many of the methods developed for single-cell RNAseq are not easily applicable, and need to be adapted. Methods have therefore been developed specifically for scATACseq data (Granja et al. 2021; Thibodeau et al. 2021).

This vignette presents different approaches to doublet detection in single-cell ATAC-seq implemented in the package: the first is an adaptation of scDblFinder, the second a reimplementation of the AMULET method from Thibodeau et al. (2021). The latter has the advantage of capturing homotypic doublets, but does not perform well in all datasets, and especially requires the cells to have a high library size. We therefore next present two ways of combining the two.

2 Applying the scDblFinder method

With default parameters, the scDblFinder method performs very poorly on scATACseq data due to the increase spread of the reads across many features. Since working with all features (i.e. tiles or peaks) is computationally very expensive, an alternative approach is to begin by reducing the size of the dataset, not through selection (as in scRNAseq), but by aggregating correlated features into a relatively small set. This has the advantage of using all information, as well as making the count data more continuous. This method yields comparable performance to specialized single-cell ATACseq software (Germain et al., 2021).

The feature aggregation can be triggered using the aggregateFeatures=TRUE argument, which will aggregate peak or tile counts into the number of meta-features defined by the nfeatures. If the number of meta-features is low (which we recommend), the meta-features can be directly used to calculated distances rather than going through the SVD step (which can be triggered with the processing argument). Such an example would be:

suppressPackageStartupMessages(library(scDblFinder))
# we use a dummy SingleCellExperiment as example:
sce <- mockDoubletSCE(ngenes=300)
# setting low number of artificial doublets (same as ncells) just for speedup:
sce <- scDblFinder(sce, artificialDoublets=1, aggregateFeatures=TRUE, nfeatures=25, processing="normFeatures")
## Aggregating features...
## Creating ~526 artificial doublets...
## Dimensional reduction
## Evaluating kNN...
## Training model...
## iter=0, 23 cells excluded from training.
## iter=1, 28 cells excluded from training.
## iter=2, 33 cells excluded from training.
## Threshold found:0.562
## 22 (4.2%) doublets called

If you encounter problems running the aggregation-based approach on large datasets, first make sure you have the mbkmeans package installed.

3 Using the Amulet method

The AMULET method from Thibodeau et al. (2021) is based on the assumption that, in a diploid cell, any given genomic region should be captured at most twice. Therefore, cells with loci covered by more than two fragments are indicative of the droplet being a doublet. Of note, this approach has the advantage of capturing homotypic doublets, which instead tend to be missed by other methods. Since it was only available in the form of a mixture of java and python scripts, we re-implemented the method in scDblFinder (see ?amulet), leading to equal or superior results to the original implementation (Germain et al. 2021).

As in the original implementation, we recommend excluding the mitochondrial and sex chromosomes, as well as repetitive regions. This can be specified with the regionsToExclude argument (see the underlying ?getFragmentOverlaps). It can be used as follows:

# here we use a dummy fragment file for example:
fragfile <- system.file("extdata", "example_fragments.tsv.gz", package="scDblFinder")

# we might also give a GRanges of repeat elements, so that these regions are excluded:
suppressPackageStartupMessages(library(GenomicRanges))
repeats <- GRanges("chr6", IRanges(1000,2000))
# it's better to combine these with mitochondrial and sex chromosomes
otherChroms <- GRanges(c("M","chrM","MT","X","Y","chrX","chrY"),IRanges(1L,width=10^8))
# here since I don't know what chromosome notation you'll be using I've just put them all,
# although this will trigger a warning when combining them:
toExclude <- suppressWarnings(c(repeats, otherChroms))
# we then launch the method
res <- amulet(fragfile, regionsToExclude=toExclude)
## Fragment file is not tabix-indexed, requiring thewhole file to be imported in memory.
## 19:13:49 - Splitting and subsetting barcodes...
## 19:13:49 - Obtaining overlaps...
res
##          nFrags uniqFrags nAbove2 total.nAbove2     p.value     q.value
## barcode1    878       878       1             1 0.475069053 0.791781755
## barcode2   2401      2401       0             0 0.798103482 0.798103482
## barcode3   2325      2325       1             1 0.475069053 0.791781755
## barcode4   1882      1882       0             0 0.798103482 0.798103482
## barcode5   1355      1355       6             6 0.001335761 0.006678806

The results is a data.frame with statistics for each barcode, including a p-value. In contrast to the scDblFinder score, a lower p-value here is indicative of the droplet being more likely to be a doublet (as in the original method). By default, only the barcodes with a minimum number of reads are considered, but it is possible to specify the droplets for which to gather statistics using the barcodes argument.

While the package includes an implementation that works based on peak/tile count matrices (see ?amuletFromCounts), it has a much lower performance with respect to the one based directly on the fragment files (see ?amulet), and we therefore discourage its use.

The workhorse behind the amulet function is the getFragmentOverlaps, which also includes all of the relevant arguments. If the fragment files are not Tabix-indexed, the whole fragment file will have to be loaded in memory for processing; while this ensures relatively rapid computation, it has high memory requirements. Therefore, if the fragment file is Tabix-indexed (as is for instance done as part of the ArchR pipeline), it will be read and processed per chromosome, which is a little slower due to overhead, but keeps memory requirements rather low. This behavior can be disabled by specifying fullInMemory=TRUE.

4 Combining mehtods

While the scDblFinder-based approach generally performs well, none of the two approach is optimal across all datasets tested. We therefore investigated two strategies for combining the rationales of each approach.

The Amulet method tends to perform best with datasets that have homotypic doublets and where cells have a high library size (i.e. median library size per cell of 10-15k reads), while the scDblFinder-based approach works better for heterotypic doublets. Until an optimal solution is found, we recommend using multiple approaches to inform decisions, in particular using the p-value combination method below.

4.1 The Clamulet method

The clamulet method (Classification-powered Amulet-like method) operates similarly to the scDblFinder method, but generates artificial doublets by operating on the fragment coverages. This has the advantage that the number of loci covered by more than two reads can be computed for artificial doublets, enabling the use of this feature (along with the kNN-based ones) in a classification scheme. It however has the disadvantage of being rather slow and memory hungry, and appears to be outperformed by a simple p-value combination of the two methods (see below). We therefore do not recommend its usage.

The clamulet method uses the aforementioned aggregation approach, and its usage includes a number of arguments from both the scDblFinder and amulet method (see in particular ?getFragmentOverlaps):

# not run
d <- clamulet("path/to/fragments.tsv.gz")

Since our dummy fragment file is so small (5 barcodes), here we’ll have to adjust the arguments for an example to run:

d <- clamulet(fragfile, k=2, nfeatures=3)
## 19:13:51 - Reading full fragments...
## 19:13:51 - Splitting and subsetting barcodes...
## 19:13:51 - Computing coverages
## 19:13:51 - Obtaining windows
## 19:13:51 - Obtaining window counts
## 19:13:51 - Aggregating features
## Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
## TRUE, : You're computing too large a percentage of total singular values, use a
## standard svd instead.
## 19:13:51 - Computing features for artificial doublets
## 19:13:51 - Counting overlaps for real cells
## 19:13:51 - Counting overlaps for artificial doublets
## 19:13:51 - Scoring network
## 19:13:52 - Iterative training
## iter=0, 0 cells excluded from training.
## iter=1, 0 cells excluded from training.
## 19:13:52 Done!
d
##          total nAbove2 total.nAbove2   weighted ratio.k2 include.in.training
## barcode1    23       1             1 0.08405864      0.5                TRUE
## barcode2    17       0             0        NaN      1.0                TRUE
## barcode3     9       1             1 1.00000000      1.0                TRUE
## barcode4    12       0             0        NaN      1.0                TRUE
## barcode5    21       6             6 0.09141137      0.5                TRUE
##              score
## barcode1 0.5491791
## barcode2 0.3417997
## barcode3 0.3417997
## barcode4 0.3417997
## barcode5 0.3417997

The score can then be interpreted as for scDblFinder. We however note that this method proved inferior to alternatives.

4.2 Simple p-value combination

The amulet and scDblFinder scores above can be simply combined by treating them as p-values and aggregating them (here using Fisher’s method from the aggregation package, but see also the metap package):

res$scDblFinder.p <- 1-colData(sce)[row.names(res), "scDblFinder.score"]
res$combined <- apply(res[,c("scDblFinder.p", "p.value")], 1, FUN=function(x){
  x[x<0.001] <- 0.001 # prevent too much skew from very small or 0 p-values
  suppressWarnings(aggregation::fisher(x))
})

We found this to perform better than averaging the scores or their ranks, and while it is not the very best method in any of the datasets tested, it has a more robust performance overall (see Germain et al., 2021).

5 References

Appendix

Jeffrey M. Granja et al., “ArchR Is a Scalable Software Package for Integrative Single-Cell Chromatin Accessibility Analysis,” Nature Genetics, February 25, 2021, 1–9, https://doi.org/10.1038/s41588-021-00790-6

Asa Thibodeau et al., “AMULET: A Novel Read Count-Based Method for Effective Multiplet Detection from Single Nucleus ATAC-Seq Data,” Genome Biology 22, no. 1 (December 2021): 252, https://doi.org/10.1186/s13059-021-02469-x

Pierre-Luc Germain et al., “Doublet Identification in Single-Cell Sequencing Data Using ScDblFinder” (F1000Research, September 28, 2021), https://doi.org/10.12688/f1000research.73600.1

Session information

sessionInfo()
## R Under development (unstable) (2024-03-18 r86148)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## 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       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] bluster_1.13.0              scDblFinder_1.17.3         
##  [3] scater_1.31.2               ggplot2_3.5.0              
##  [5] scran_1.31.3                scuttle_1.13.1             
##  [7] ensembldb_2.27.1            AnnotationFilter_1.27.0    
##  [9] GenomicFeatures_1.55.4      AnnotationDbi_1.65.2       
## [11] scRNAseq_2.17.6             SingleCellExperiment_1.25.0
## [13] SummarizedExperiment_1.33.3 Biobase_2.63.0             
## [15] GenomicRanges_1.55.4        GenomeInfoDb_1.39.9        
## [17] IRanges_2.37.1              S4Vectors_0.41.5           
## [19] BiocGenerics_0.49.1         MatrixGenerics_1.15.0      
## [21] matrixStats_1.2.0           BiocStyle_2.31.0           
## 
## loaded via a namespace (and not attached):
##   [1] jsonlite_1.8.8            magrittr_2.0.3           
##   [3] magick_2.8.3              ggbeeswarm_0.7.2         
##   [5] gypsum_0.99.15            farver_2.1.1             
##   [7] rmarkdown_2.26            BiocIO_1.13.0            
##   [9] zlibbioc_1.49.3           vctrs_0.6.5              
##  [11] memoise_2.0.1             Rsamtools_2.19.4         
##  [13] DelayedMatrixStats_1.25.1 RCurl_1.98-1.14          
##  [15] base64enc_0.1-3           htmltools_0.5.7          
##  [17] S4Arrays_1.3.6            AnnotationHub_3.11.3     
##  [19] curl_5.2.1                BiocNeighbors_1.21.2     
##  [21] xgboost_1.7.7.1           Rhdf5lib_1.25.1          
##  [23] SparseArray_1.3.4         rhdf5_2.47.6             
##  [25] sass_0.4.9                alabaster.base_1.3.23    
##  [27] bslib_0.6.1               alabaster.sce_1.3.3      
##  [29] httr2_1.0.0               cachem_1.0.8             
##  [31] GenomicAlignments_1.39.4  igraph_2.0.3             
##  [33] mime_0.12                 lifecycle_1.0.4          
##  [35] pkgconfig_2.0.3           rsvd_1.0.5               
##  [37] Matrix_1.6-5              R6_2.5.1                 
##  [39] fastmap_1.1.1             GenomeInfoDbData_1.2.11  
##  [41] digest_0.6.35             colorspace_2.1-0         
##  [43] dqrng_0.3.2               irlba_2.3.5.1            
##  [45] ExperimentHub_2.11.1      aws.signature_0.6.0      
##  [47] RSQLite_2.3.5             beachmat_2.19.1          
##  [49] labeling_0.4.3            filelock_1.0.3           
##  [51] fansi_1.0.6               httr_1.4.7               
##  [53] abind_1.4-5               compiler_4.4.0           
##  [55] bit64_4.0.5               withr_3.0.0              
##  [57] BiocParallel_1.37.1       viridis_0.6.5            
##  [59] DBI_1.2.2                 highr_0.10               
##  [61] HDF5Array_1.31.6          alabaster.ranges_1.3.3   
##  [63] alabaster.schemas_1.3.1   MASS_7.3-60.2            
##  [65] rappdirs_0.3.3            DelayedArray_0.29.9      
##  [67] rjson_0.2.21              tools_4.4.0              
##  [69] vipor_0.4.7               beeswarm_0.4.0           
##  [71] glue_1.7.0                restfulr_0.0.15          
##  [73] rhdf5filters_1.15.4       grid_4.4.0               
##  [75] Rtsne_0.17                cluster_2.1.6            
##  [77] generics_0.1.3            gtable_0.3.4             
##  [79] data.table_1.15.2         metapod_1.11.1           
##  [81] BiocSingular_1.19.0       ScaledMatrix_1.11.1      
##  [83] xml2_1.3.6                utf8_1.2.4               
##  [85] XVector_0.43.1            ggrepel_0.9.5            
##  [87] BiocVersion_3.19.1        pillar_1.9.0             
##  [89] limma_3.59.6              dplyr_1.1.4              
##  [91] BiocFileCache_2.11.1      lattice_0.22-6           
##  [93] rtracklayer_1.63.1        bit_4.0.5                
##  [95] tidyselect_1.2.1          locfit_1.5-9.9           
##  [97] Biostrings_2.71.4         knitr_1.45               
##  [99] gridExtra_2.3             bookdown_0.38            
## [101] ProtGenerics_1.35.4       edgeR_4.1.18             
## [103] xfun_0.42                 statmod_1.5.0            
## [105] lazyeval_0.2.2            yaml_2.3.8               
## [107] evaluate_0.23             codetools_0.2-19         
## [109] tibble_3.2.1              alabaster.matrix_1.3.13  
## [111] BiocManager_1.30.22       cli_3.6.2                
## [113] munsell_0.5.0             jquerylib_0.1.4          
## [115] Rcpp_1.0.12               dbplyr_2.5.0             
## [117] png_0.1-8                 XML_3.99-0.16.1          
## [119] parallel_4.4.0            blob_1.2.4               
## [121] aws.s3_0.3.21             sparseMatrixStats_1.15.0 
## [123] bitops_1.0-7              viridisLite_0.4.2        
## [125] alabaster.se_1.3.4        scales_1.3.0             
## [127] purrr_1.0.2               crayon_1.5.2             
## [129] rlang_1.1.3               cowplot_1.1.3            
## [131] KEGGREST_1.43.0