R/motifCountMatrix.R

Defines functions motifCountMatrix

Documented in motifCountMatrix

#' Motif count matrix.
#' 
#' The function can be used to retrieve a subset of the motif count matrix
#' stored in a promoter.DB object, for a set of genes given as input. The
#' promoter.DB objets are as generated by the functions makePromoterDBfromFimo
#' or makePromoterDBfromRE.
#' 
#' 
#' @param Genes A list of the genes of interest.
#' @param promoterDB Promoter.DB object,
#' @param strand A character string that can take value: "plus", "minus" or
#' "both".
#' @return A promoter.DB object
#' @note %% ~~further notes~~
#' @author %% ~~who you are~~
#' @seealso %% ~~objects to See Also as \code{\link{help}}, ~~~
#' @references
#' @keywords ~kwd1 ~kwd2
#' @examples
#' 
#' 
#' @export motifCountMatrix
motifCountMatrix <- function(Genes, promoterDB = "promoter.DB", strand = "both") {
    load(promoterDB)
    Allgenes = rownames(Strands[[1]])
    
    # test if all genes exist in promoter DB
    t1 = which(!(Genes %in% Allgenes))
    if (length(t1) > 0) {
        message("Gene(s) ", paste(Genes[t1], collapse = ""), " not found from promoter DB. Dropping from analysis.")
        Genes = Genes[Genes %in% Allgenes]
    }
    tfbs = Strands[[strand]][Genes, ]
    tfbs = tfbs[, which(colSums(tfbs > 0) > 0)]
    return(tfbs)
}
jsalojar/TFbindR documentation built on Dec. 9, 2019, 12:16 a.m.