diff --git a/R/analysis.R b/R/analysis.R index ee02b79..77583bb 100644 --- a/R/analysis.R +++ b/R/analysis.R @@ -49,7 +49,7 @@ netAnalysis_contribution <- function(object, signaling, signaling.name = NULL, w pairLR <- pairLR[pairLR.name.use,] } - prob <- prob[,,pairLR.name.use] + prob <- prob[,,pairLR.name.use, drop=FALSE] if (length(dim(prob)) == 2) { prob <- replicate(1, prob, simplify="array") @@ -981,7 +981,7 @@ rankNet <- function(object, slot.name = "netP", mode = c("comparison", "single") } } idx.t <- setdiff(1:nrow(prob), sources.use) - prob[idx.t, , ] <- 0 + prob[idx.t, , ,drop=FALSE] <- 0 } if (!is.null(targets.use)) { if (is.character(targets.use)) { @@ -992,7 +992,7 @@ rankNet <- function(object, slot.name = "netP", mode = c("comparison", "single") } } idx.t <- setdiff(1:nrow(prob), targets.use) - prob[ ,idx.t, ] <- 0 + prob[ ,idx.t, ,drop=FALSE] <- 0 } if (sum(prob) == 0) { stop("No inferred communications for the input!") @@ -1058,7 +1058,7 @@ rankNet <- function(object, slot.name = "netP", mode = c("comparison", "single") } } idx.t <- setdiff(1:nrow(prob), targets.use) - prob[ ,idx.t, ] <- 0 + prob[ ,idx.t, , drop=FALSE] <- 0 } if (sum(prob) == 0) { stop("No inferred communications for the input!") diff --git a/R/modeling.R b/R/modeling.R index 2db536d..fad8c70 100644 --- a/R/modeling.R +++ b/R/modeling.R @@ -375,10 +375,10 @@ computeCommunProbPathway <- function(object = NULL, net = NULL, pairLR.use = NUL group <- factor(pairLR.use$pathway_name, levels = pathways) prob.pathways <- aperm(apply(prob, c(1, 2), by, group, sum), c(2, 3, 1)) pathways.sig <- pathways[apply(prob.pathways, 3, sum) != 0] - prob.pathways.sig <- prob.pathways[,,pathways.sig] + prob.pathways.sig <- prob.pathways[,,pathways.sig, drop=FALSE] idx <- sort(apply(prob.pathways.sig, 3, sum), decreasing=TRUE, index.return = TRUE)$ix pathways.sig <- pathways.sig[idx] - prob.pathways.sig <- prob.pathways.sig[, , idx] + prob.pathways.sig <- prob.pathways.sig[, , idx, drop=FALSE] if (is.null(object)) { netP = list(pathways = pathways.sig, prob = prob.pathways.sig)