#' Calculate the co-dependency index
#'
#' Calculate P-values from the binomial distribution and take their negative
#' logarithms as an indicator of coexpression, as proposed by Mohammadi et al.
#' in doi: 10.1101/241646.
#'
#' @param mat a matrix of data, with samples in rows and features in columns
#'
#' @return the binomial P-values between non-zero/missing values in each pair of
#' columns
#'
#' @importFrom stats pbinom
#' @export
binomial = function(mat) {
present = !is.na(mat) & mat > 0
size = nrow(mat)
q = crossprod(present)
prob = crossprod(t(colMeans(present)))
cor = pbinom(q, size, prob, lower.tail = F)
dimnames(cor) = list(colnames(mat), colnames(mat))
-log10(cor)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.