R/eigenCor.R

Defines functions eigenCor

Documented in eigenCor

#' @title Computing eigen-gene or eigen-microRNAs based connectivity
#'
#' @description \code{eigenCor} computes eigen-gene or eigen-microRNAs based connectivity. k_j = cor(x_j, E)
#'
#' @param exp.m A matrix, the normalized gene/microRNA expression dataset, should be a numeric matrix, with rows referring to genes/microRNAs and columns to samples.
#' @param eigen.exp A vector of computed eigen-gene or eigen-microRNAs of the same module, one entry of the output list by \code{\link[mirNet]{comEigenGene}}.
#'
#' @return A data matrix of computed correlation coefficients and P-values.
#'
#' @export eigenCor
#'
#' @examples
#' eigenCor(exp.m, eigen.exp)



eigenCor <- function(exp.m, eigen.exp){

    L <- nrow(exp.m)
    res <- matrix(nrow = L, ncol = 3, dimnames = list(rownames(exp.m), c('r', 'p', 'fdr')))
    for(i in 1:L){
        cor.o <- cor.test(eigen.exp, as.numeric(exp.m[i, ]))
        res[i, 'r'] <- cor.o$est
        res[i, 'p'] <- cor.o$p.value
    }

    res[, 'fdr'] <- p.adjust(res[, 'p'], 'fdr')
    res
}
YC3/mirNet documentation built on Sept. 3, 2020, 3:25 a.m.