From bb3203dc8b987e5a654d273b64b8249ba604e034 Mon Sep 17 00:00:00 2001 From: Markus Riester Date: Thu, 28 Mar 2024 14:56:40 -0400 Subject: [PATCH] Attempt in fixing #356. --- NEWS | 2 ++ R/createNormalDatabase.R | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 4038eb8..6ecd9d4 100755 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ BUGFIXES o Bugfix #296 was not merged into the developer branch and did not make it into 2.8.0. + o Log ratios not shiften to median of sample medians as intended (#356). + Thanks @sleyn. Changes in version 2.8.0 diff --git a/R/createNormalDatabase.R b/R/createNormalDatabase.R index 63e5b25..aa2b35b 100644 --- a/R/createNormalDatabase.R +++ b/R/createNormalDatabase.R @@ -204,17 +204,17 @@ optimal.off.target.counts = 120, plot = FALSE, ...) { fcnts_std[, i] <- fcnts_std[,i] / iv } } else { - fcnts_std <- apply(fcnts,2,function(x) x/fcnts_interval_medians) + fcnts_std <- apply(fcnts, 2, function(x) x / fcnts_interval_medians) } - fcnts_interval_non_zero_medians <- apply(fcnts_std, 1, function(x) median(x[x>0])) - fcnts_std_imp <- apply(fcnts_std, 2, function(x) { x[x<=0] <- fcnts_interval_non_zero_medians[x<=0]; x}) - p=0.001 - li <- quantile(as.vector(fcnts_std_imp), probs= c(p, 1-p)) + fcnts_interval_non_zero_medians <- apply(fcnts_std, 1, function(x) median(x[x > 0])) + fcnts_std_imp <- apply(fcnts_std, 2, function(x) { x[x <= 0] <- fcnts_interval_non_zero_medians[x <= 0]; x}) + p <- 0.001 + li <- quantile(as.vector(fcnts_std_imp), probs = c(p, 1 - p)) fcnts_std_trunc <- fcnts_std_imp fcnts_std_trunc[fcnts_std_imp < li[1]] <- li[1] fcnts_std_trunc[fcnts_std_imp > li[2]] <- li[2] fcnts_std_final <- apply(fcnts_std_trunc, 2, function(x) log2(x / median(x))) - fcnts_std_final - median(apply(fcnts_std_final,2,median)) + fcnts_std_final <- fcnts_std_final - median(apply(fcnts_std_final, 2, median)) s <- svd(fcnts_std_final) ret <- list(