From 13f23e2f515280b33f044f64f0a9bad0b22673ef Mon Sep 17 00:00:00 2001 From: Suzanne Jin Date: Wed, 16 Oct 2024 17:23:56 +0200 Subject: [PATCH] modify runNormalization so that it can handle other thetas --- R/2c-propd-experimental.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/R/2c-propd-experimental.R b/R/2c-propd-experimental.R index 02176a7..a3745fc 100644 --- a/R/2c-propd-experimental.R +++ b/R/2c-propd-experimental.R @@ -17,15 +17,11 @@ runNormalization <- function(object, norm.factors) { if (!inherits(object, "propd")) { stop("Please provide a propd object.") } - - if (!object@active == "theta_d") { - stop("Make theta_d the active theta.") - } - if (!identical(length(norm.factors), nrow(object@counts))) { stop("The norm factors should have one value for each subject.") } + # compute thetas newCounts <- cbind(norm.factors, object@counts) newPD <- propd( @@ -35,13 +31,19 @@ runNormalization <- function(object, norm.factors) { p = 0, weighted = object@weighted ) + if (object@active == "theta_mod") { + newPD <- updateF(newPD, moderated = TRUE) + } + newPD <- setActive(newPD, object@active) + # parse thetas for each gene rawRes <- newPD@results perFeature <- rawRes[rawRes$Pair == 1,] if (!identical(perFeature$Partner, 2:(ncol(newCounts)))) stop("DEBUG ERROR #GET001.") thetas <- perFeature$theta names(thetas) <- colnames(object@counts) + return(thetas) }