Skip to content

Commit

Permalink
undirectional scores for NMF
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuvad committed Apr 18, 2023
1 parent b10933a commit 719dbd8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/common_sc.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ cluster_graph <- function(sce, snn = 20, alg = igraph::cluster_walktrap, ...) {
#----factor interpretation----
doFA <- function(sce, gsc, dimred = c('PCA', 'NMF'), ncomponents = 15) {
dimred = match.arg(dimred)
directional = dimred %in% c('PCA') #are gene weights directional?
attr_name = switch(
dimred,
PCA = 'rotation',
Expand All @@ -216,7 +217,7 @@ doFA <- function(sce, gsc, dimred = c('PCA', 'NMF'), ncomponents = 15) {
gsc = gsc[sapply(gsc, function(x)
sum(GSEABase::geneIds(x) %in% rownames(gene_weights)) >= 5)]
franks = singscore::rankGenes(gene_weights)
fsea = singscore::multiScore(franks, gsc)$Scores
fsea = singscore::multiScore(franks, gsc, centerScore = directional)$Scores
attr(fsea, 'weights') = gene_weights
fsea
}
Expand Down

0 comments on commit 719dbd8

Please sign in to comment.