Skip to content

Commit

Permalink
Fix a bug in smoothData.R
Browse files Browse the repository at this point in the history
  • Loading branch information
sqjin committed Jun 19, 2024
1 parent 08a5812 commit 88c2e13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -837,15 +837,15 @@ smoothData <- function(object, method = c("netSmooth"), adj = NULL, alpha=0.5, n
}
data <- as.matrix(object@data.signaling)
normalizeAdjMatrix <- match.arg(normalizeAdjMatrix)
stopifnot(is(adjMatrix, 'matrix') || is(adjMatrix, 'sparseMatrix'))
stopifnot(is(adj, 'matrix') || is(adj, 'sparseMatrix'))
stopifnot((is.numeric(alpha) && (alpha > 0 && alpha < 1)))
if(sum(Matrix::rowSums(adjMatrix)==0)>0) stop("PPI cannot have zero rows/columns")
if(sum(Matrix::colSums(adjMatrix)==0)>0) stop("PPI cannot have zero rows/columns")
if(sum(Matrix::rowSums(adj)==0)>0) stop("PPI cannot have zero rows/columns")
if(sum(Matrix::colSums(adj)==0)>0) stop("PPI cannot have zero rows/columns")
if(is.numeric(alpha)) {
if(alpha<0 | alpha > 1) {
stop('alpha must be between 0 and 1')
}
data.projected <- projectAndRecombine(data, adjMatrix, alpha,normalizeAdjMatrix=normalizeAdjMatrix)
data.projected <- projectAndRecombine(data, adj, alpha,normalizeAdjMatrix=normalizeAdjMatrix)
} else stop("unsupported alpha value: ", class(alpha))
object@data.smooth <- data.projected
return(object)
Expand Down

0 comments on commit 88c2e13

Please sign in to comment.