R/RUVphospho.R

Defines functions RUVphospho

Documented in RUVphospho

#' RUV for phosphoproteomics data normalisation
#'
#' This is a wrapper implementation of RUVIII for phosphoproteomics data normalisation. This function will call
#' tailImpute function to impute all the missing values (if there is any) in the phosphoproteomics data for
#' applying RUVIII. It will then return the normalised values for quantified phosphosites and remove imputed values.
#'
#' @usage RUVphospho(Y, M, ctl, k=NULL, ...)
#'
#' @param Y a matrix with rows correspond to phosphosites and columns correspond to samples.
#' @param M is the design matrix as defined in RUVIII.
#' @param ctl is the stable phosphosites (or negative controls as defined in RUVIII).
#' @param k is the number of unwanted factors as defined in RUVIII.
#' @param ... additional parameters that may be passed to RUVIII.
#' @export
#'
RUVphospho <- function(Y, M, ctl, k=NULL, ...)
{
  Y.complete <- c()
  if (sum(is.na(Y)) > 0) {
    Y.complete <- t(tailImpute(Y))
  } else {
    Y.complete <- t(Y)
  }

  Y.new <- t(RUVIII(Y=Y.complete, M=M, k=k, ctl=ctl, return.info = FALSE, ...))

  if(sum(is.na(Y)) > 0) {
    Y.new[which(is.na(Y))] <- NA
    return(Y.new)
  } else {
    return(Y.new)
  }
}
SydneyBioX/phosphoR documentation built on May 20, 2019, 12:58 a.m.