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 2 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
6 changes: 3 additions & 3 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 @@ -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
2 changes: 1 addition & 1 deletion R/modeling.R
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ 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]
Copy link
Owner

Choose a reason for hiding this comment

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

Can you also change line 381 prob.pathways.sig <- prob.pathways.sig[, , idx] to prob.pathways.sig <- prob.pathways.sig[, , idx, drop=FALSE]

Expand Down