| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | f_Doublet_get_pK <- function(sce, pcs){sweep.res <- DoubletFinder::paramSweep_v3(sce, PCs = 1:pcs, sct = T, num.cores=4)
 sweep.stats <- DoubletFinder::summarizeSweep(sweep.res, GT = FALSE)
 bcmvn <- DoubletFinder::find.pK(sweep.stats)
 pK_bcmvn <- as.numeric(as.character(bcmvn$pK[which.max(bcmvn$BCmetric)]))
 pK_bcmvn
 }
 f_DoubletFinder <- function(sce, pcs, pK_bcmvn, DoubletRate, seurat_clusters){
 homotypic.prop <- DoubletFinder::modelHomotypic(seurat_clusters)
 nExp_poi <- round(DoubletRate*length(seurat_clusters))
 nExp_poi.adj <- round(nExp_poi*(1-homotypic.prop))
 sce <- DoubletFinder::doubletFinder_v3(sce, PCs = 1:pcs,
 pN = 0.25, pK = pK_bcmvn,
 nExp = nExp_poi.adj, reuse.pANN = FALSE,
 sct = T)
 sce
 }
 
 |