From 6f82238ea97f393f6ef4c475f3a19ccb3a88898f Mon Sep 17 00:00:00 2001 From: plger Date: Fri, 6 Sep 2024 14:00:03 +0200 Subject: [PATCH] added caps on prop of cells exluded from training --- R/scDblFinder.R | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/R/scDblFinder.R b/R/scDblFinder.R index 00d7d35..dbdbb86 100644 --- a/R/scDblFinder.R +++ b/R/scDblFinder.R @@ -648,12 +648,23 @@ scDblFinder <- function( while(iter>0){ # remove cells with a high chance of being doublets from the training, # as well as unidentifiable artificial doublets - w <- which( (d$type=="real" & - doubletThresholding(d, dbr=dbr, dbr.sd=dbr.sd, stringency=0.7, - perSample=perSample, - returnType="call")=="doublet") | - (d$type=="doublet" & d$score sum(d$type=="real")/3){ + # enforce max prop excluded + w1 <- head(order(d$type!="real", -d$score), + floor(0.2*sum(d$type=="real"))) + } + w2 <- which(d$type=="doublet" & d$score sum(d$type=="doublet")/4){ + # enforce max prop excluded + w2 <- head(order(d$type=="real", d$score), + floor(0.1*sum(d$type!="real"))) + } + w <- unique(c(w1,w2,which(!d$include.in.training))) + if(verbose) message("iter=",max.iter-iter,", ", length(w), " cells excluded from training.") d$score <- tryCatch({