Skip to content

Commit

Permalink
Merge pull request #64 from suzannejin/master
Browse files Browse the repository at this point in the history
modify runNormalization so that it can handle other thetas
  • Loading branch information
suzannejin authored Oct 17, 2024
2 parents ffc2c20 + 13f23e2 commit 1d29836
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/2c-propd-experimental.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
}

Expand Down

0 comments on commit 1d29836

Please sign in to comment.