Detect doublet with DoubletFinder. Package "Seurat" and "DoubletFinder" would be required to run this function.
This wrapper runs Seurat PCA workflow (NormalizeData,
FindVariableFeatures, ScaleData, RunPCA) with all default settings on each
dataset, and then calls DoubletFinder::doubletFinder
. Users that
prefer having more control on the preprocessing part might consider creating
single-sample Seurat object with
CreateSeuratObject(rawData(object, "datasetName"))
.
Usage
runDoubletFinder(
object,
useDatasets = NULL,
PCs = 1:10,
nNeighbors = 20,
nExp = NULL,
verbose = getOption("ligerVerbose", TRUE),
...
)
Arguments
- object
A liger object.
- useDatasets
A character vector of the names, a numeric or logical vector of the index of the datasets to run
DoubletFinder::doubletFinder
with. DefaultNULL
applies to all datasets.- PCs
Specific principal components to use. Default
1:10
.- nNeighbors
Number of the PC neighborhood size used to compute pANN. See "See Also". Scalar for all used datasets or vector for each. Default
20
.- nExp
The total number of doublet predictions produced. Scalar for all used datasets or vector for each. Default
NULL
sets a 0.15 proportion.- verbose
Logical. Whether to show information of the progress. Default
getOption("ligerVerbose")
orTRUE
if users have not set.- ...
Additional arguments passed to
DoubletFinder::doubletFinder
.
Value
Updated object
with variables DoubletFinder_pANN
and
DoubletFinder_classification
updated in cellMeta
slot
Examples
if (requireNamespace("DoubletFinder", quietly = TRUE)) {
pbmc <- runDoubletFinder(pbmc)
print(cellMeta(pbmc))
}
#> ℹ Running DoubletFinder on dataset "ctrl"
#> Loading required package: Seurat
#> Loading required package: SeuratObject
#> Loading required package: sp
#>
#> Attaching package: ‘SeuratObject’
#> The following objects are masked from ‘package:base’:
#>
#> intersect, t
#> Loading required package: fields
#> Loading required package: spam
#> Warning: package ‘spam’ was built under R version 4.4.1
#> Spam version 2.11-0 (2024-10-03) is loaded.
#> Type 'help( Spam)' or 'demo( spam)' for a short introduction
#> and overview of this package.
#> Help for individual functions is also obtained by adding the
#> suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
#>
#> Attaching package: ‘spam’
#> The following objects are masked from ‘package:base’:
#>
#> backsolve, forwardsolve
#> Loading required package: viridisLite
#>
#> Try help(fields) to get started.
#> Loading required package: KernSmooth
#> KernSmooth 2.23 loaded
#> Copyright M. P. Wand 1997-2009
#> [1] "Creating 100 artificial doublets..."
#> [1] "Creating Seurat object..."
#> [1] "Normalizing Seurat object..."
#> Normalizing layer: counts
#> [1] "Finding variable genes..."
#> Finding variable features for layer counts
#> [1] "Scaling data..."
#> Centering and scaling data matrix
#> [1] "Running PCA..."
#> [1] "Calculating PC distance matrix..."
#> [1] "Computing pANN..."
#> [1] "Classifying doublets.."
#> ✔ Running DoubletFinder on dataset "ctrl" ... done
#>
#> ℹ Running DoubletFinder on dataset "stim"
#> [1] "Creating 100 artificial doublets..."
#> [1] "Creating Seurat object..."
#> [1] "Normalizing Seurat object..."
#> Normalizing layer: counts
#> [1] "Finding variable genes..."
#> Finding variable features for layer counts
#> [1] "Scaling data..."
#> Centering and scaling data matrix
#> [1] "Running PCA..."
#> [1] "Calculating PC distance matrix..."
#> [1] "Computing pANN..."
#> [1] "Classifying doublets.."
#> ✔ Running DoubletFinder on dataset "stim" ... done
#>
#> DataFrame with 600 rows and 9 columns
#> dataset barcode nUMI nGene
#> <factor> <character> <numeric> <integer>
#> ctrl_AAACATACCTCGCT.1 ctrl ctrl_AAACATACCTCGCT.1 2151 102
#> ctrl_AAACGGCTCTTCGC.1 ctrl ctrl_AAACGGCTCTTCGC.1 1916 103
#> ctrl_AACACTCTAAGTAG.1 ctrl ctrl_AACACTCTAAGTAG.1 1869 95
#> ctrl_AACCGCCTCAGGAG.1 ctrl ctrl_AACCGCCTCAGGAG.1 733 84
#> ctrl_AACGTTCTTCCGTC.1 ctrl ctrl_AACGTTCTTCCGTC.1 573 76
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 stim stim_TTCATGACTTATCC.1 1091 101
#> stim_TTCATGACTTCAGG.1 stim stim_TTCATGACTTCAGG.1 431 86
#> stim_TTCGGAGATTTCAC.1 stim stim_TTCGGAGATTTCAC.1 1344 102
#> stim_TTGACACTTCCTGC.1 stim stim_TTGACACTTCCTGC.1 1423 105
#> stim_TTTGCATGAACGAA.1 stim stim_TTTGCATGAACGAA.1 2818 120
#> mito ribo hemo DoubletFinder_pANN
#> <numeric> <numeric> <numeric> <numeric>
#> ctrl_AAACATACCTCGCT.1 0 10.83217 0 0.0125
#> ctrl_AAACGGCTCTTCGC.1 0 20.25052 0 0.0125
#> ctrl_AACACTCTAAGTAG.1 0 5.08293 0 0.0125
#> ctrl_AACCGCCTCAGGAG.1 0 42.70123 0 0.0125
#> ctrl_AACGTTCTTCCGTC.1 0 38.04538 0 0.0125
#> ... ... ... ... ...
#> stim_TTCATGACTTATCC.1 0 8.61595 0 0.0125
#> stim_TTCATGACTTCAGG.1 0 41.29930 0 0.0125
#> stim_TTCGGAGATTTCAC.1 0 8.85417 0 0.0125
#> stim_TTGACACTTCCTGC.1 0 11.94659 0 0.0125
#> stim_TTTGCATGAACGAA.1 0 9.43932 0 0.0125
#> DoubletFinder_classification
#> <character>
#> ctrl_AAACATACCTCGCT.1 Doublet
#> ctrl_AAACGGCTCTTCGC.1 Doublet
#> ctrl_AACACTCTAAGTAG.1 Doublet
#> ctrl_AACCGCCTCAGGAG.1 Doublet
#> ctrl_AACGTTCTTCCGTC.1 Doublet
#> ... ...
#> stim_TTCATGACTTATCC.1 Singlet
#> stim_TTCATGACTTCAGG.1 Singlet
#> stim_TTCGGAGATTTCAC.1 Singlet
#> stim_TTGACACTTCCTGC.1 Singlet
#> stim_TTTGCATGAACGAA.1 Singlet