R/normalizeCoProDat.R

Defines functions normalizeCoProData

Documented in normalizeCoProData

#' Normalize CoPRO data
#'
#' @param dat the CoPRO data in data.table format
#' @param method what algorithm to use to normalize the data. Currently the only supported algorithm is genome-wide linear model fit.
#'
#' @return the normalized CoPRO data, plus an additional column \code{tot} for total (i.e., normalized C + U) reads. All rows with a value of 0 for tot are removed. The column R is also removed.
#' @export
normalizeCoProData <- function(dat, method = "genomeWideLinModel") {
  if (method == "genomeWideLinModel") {
    cFactor <- 0.151; uFactor <- 0.296
    # fit <- lm(formula = R ~ C + U + 0, data = dat)
    # cFactor <- coef(fit)[["C"]]; uFactor <- coef(fit)[["U"]]
    dat[, c("C", "U") := list(cFactor * C, uFactor * U) ]
  }
}
Timothy-Barry/coproanalysis documentation built on Feb. 12, 2020, 7:33 a.m.