R/run_genie3.R

Defines functions run_genie3

Documented in run_genie3

# if (!requireNamespace("BiocManager", quietly = TRUE))
#   install.packages("BiocManager")
# BiocManager::install("GENIE3")

#' Wrapper for C3Net method
#' 
#' Conducts co-expression analysis using C3Net
#' @param x The n by p matrix of counts.
#' @return A p by p matrix of association scores.
#' @export
run_genie3 <- function(x, nTrees = 200, ...) {
  scores <- GENIE3::GENIE3(t(x), nTrees = nTrees)
  
  # GENIE3 rearranges columns of x; need to put back in orginal order.
  genes <- colnames(scores)
  index <- sapply(colnames(x), function(k) which(genes == k))
  scores <- scores[index, index]
  
  # Symmetrize the associations.
  scores <- 0.5 * (scores + t(scores))
  
  colnames(scores) <- colnames(x)
  rownames(scores) <- NULL
  
  return(scores)
}
tgrimes/dnapath2 documentation built on May 21, 2020, 5:53 p.m.