Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Update modeling.R #203

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary as we have if (length(dim(prob)) == 2) below.


if (length(dim(prob)) == 2) {
prob <- replicate(1, prob, simplify="array")
Expand Down Expand Up @@ -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)) {
Expand All @@ -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!")
Expand Down Expand Up @@ -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!")
Expand Down
4 changes: 2 additions & 2 deletions R/modeling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down