Skip to content

Commit

Permalink
scaler
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Oct 22, 2024
1 parent 3e7ab2e commit b951111
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ setGroup <- function(stana, cl) {
}



#' @noRd
scaler.NNLM <- function(nmf, target="coef") {
if (target=="basis") {
scaledW <- apply(nmf$W, 2, function(x) x / sum(x))
Sii <- apply(nmf$W, 2, function(x) sum(x))
scaledH <- apply(nmf$H, 2, function(x) {
x * Sii
})
list("W"=scaledW, "H"=scaledH)
} else {
scaledH <- apply(nmf$H, 1, function(x) x / sum(x)) %>% t()
Sii <- apply(nmf$H, 1, function(x) sum(x))
scaledW <- apply(nmf$W, 1, function(x) {
x * Sii
}) %>% t()
list("W"=scaledW, "H"=scaledH)
}

}

#' returnGenes
#' return corresponding genes queried by SNV position
#' @param stana stana object
Expand Down

0 comments on commit b951111

Please sign in to comment.