Skip to content

Commit d8c5a0e

Browse files
committed
fix #8
1 parent f6dbb50 commit d8c5a0e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

R/msImpute.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,16 @@ estimateLambda <- function(y, rank=NULL) mean(matrixStats::colSds(y, na.rm = TRU
221221
#' @keywords internal
222222
l2bary <- function(y, ygauss, yerank, group, a=0.2){
223223

224-
pepVars <- matrixStats::rowSds(y, na.rm = TRUE)
225-
varq75 <- quantile(pepVars, p = 0.75, na.rm=TRUE)
224+
pepSds <- matrixStats::rowSds(y, na.rm = TRUE)
225+
pepMeans <- rowMeans(y, na.rm = TRUE)
226+
pepCVs <- pepSds/pepMeans
227+
CV_cutoff <- min(0.2, median(pepCVs))
228+
varq75 <- quantile(pepSds, p = 0.75, na.rm=TRUE)
226229
#varq75 <- mean(pepVars)
227230
EBM <- ebm(y, group)
228231

229-
# if entropy is nan and variance is high, it is most likely detection limit missing
230-
w1 <- ifelse(is.nan(EBM) & (pepVars > varq75), 1-a, a)
232+
# if entropy is nan and variance is low, it is most likely detection limit missing
233+
w1 <- ifelse(is.nan(EBM) & (pepCVs < CV_cutoff), 1-a, a)
231234
w2 <- 1-w1
232235

233236
yl2 <- list()

0 commit comments

Comments
 (0)