R/fitBundles.R

Defines functions fitBundles

Documented in fitBundles

#' encapsulate limma/voom analysis for consistency with ebrowser()
#' 
#' @param kexp        A KallistoExperiment
#' @param design      A model matrix 
#' @param bundleID    The ID to bundle on (default is gene_id)
#' @param read.cutoff Exclude bundles where the maximum count is < this 
#' @param ...         any more         
#' @return            A list with elements (design, voomed, fit)
#' @importFrom edgeR DGEList
#' @importFrom edgeR calcNormFactors
#' @importFrom limma voom
#' @importFrom limma eBayes
#' @importFrom limma lmFit
#' @export
fitBundles <- function(kexp, design, bundleID="gene_id", read.cutoff=1, ...) { 

  res <- list()
  bundledCounts <- collapseBundles(kexp, bundleID=bundleID, 
                                   read.cutoff=read.cutoff, ...)
  dge <- DGEList(counts=bundledCounts)
  dge <- calcNormFactors(dge)
  res$design <- design 
  res$voomed <- voom(dge, res$design)
  res$fit <- eBayes(lmFit(res$voomed, res$design))
  return(res)

}
RamsinghLab/arkas_staging documentation built on March 14, 2021, 11:40 a.m.