From e9c50a13e57c45cbd4abfcf3c0ad0d067a861c2b Mon Sep 17 00:00:00 2001 From: kalidouBA Date: Mon, 11 Dec 2023 17:01:13 +0100 Subject: [PATCH] fix main function --- R/DICEPRO.R | 15 +++++---------- R/NMF_optim.R | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/R/DICEPRO.R b/R/DICEPRO.R index 075cff9..be081f5 100644 --- a/R/DICEPRO.R +++ b/R/DICEPRO.R @@ -72,21 +72,16 @@ DICEPRO <- function(reference, bulk, methodDeconv = "CSx", cibersortx_email = NU bulk <- as.data.frame(apply(bulk[geneIntersect, ], 2, as.numeric)) rownames(reference) <- rownames(bulk) <- geneIntersect - matrixAbundances <- performs <- normFrobs <- performs2plot <- opt <- NULL + out_Dec <- running_method(bulk, reference, methodDeconv, cibersortx_email, cibersortx_token) + k_CT <- ncol(reference) + 1 - out_Dec <- running_method(bulk, W, methodDeconv, cibersortx_email, cibersortx_token) - B_Deconv <- as.matrix(W) %*% t(out_Dec) - - k_CT <- ncol(W) - - res <- nmf_conjugate_gradient(V = bulk, W = W, H = out_Dec, k_CT+1) + res <- nmf_conjugate_gradient(V = bulk, W = reference, H = out_Dec, k = k_CT) W <- res$W - colnames(W) <- c(cellTypeName, paste0("Unknown")) + dimnames(W) <- list(geneIntersect, c(cellTypeName, paste0("Unknown"))) - out_Dec_Update <- res$H[,1:ncol(out_Dec)] + out_Dec_Update <- res$H[,-k_CT] dimnames(out_Dec_Update) <- dimnames(out_Dec) - rownames(performs2plot) <- NULL results <- list("Prediction" = out_Dec_Update, "New_signature" = W) diff --git a/R/NMF_optim.R b/R/NMF_optim.R index 233d58f..f357e00 100644 --- a/R/NMF_optim.R +++ b/R/NMF_optim.R @@ -64,7 +64,7 @@ nmf_conjugate_gradient <- function(V, k = 1, W = NULL, H = NULL) { list(W = W, H = t(H), Error = rmse_nmf) } - cl <- min(5, detectCores()) + cl <- min(5, detectCores()) result_list <- mclapply(seq(0,1,0.25), function(i) { par_nmf(i) }, mc.cores = cl)