#' Tail impute
#'
#' Tail imputation approach as implemented in Perseus.
#'
#' @usage tailImpute(mat)
#'
#' @param mat a matrix with rows correspond to phosphosites and columns correspond to samples.
#' @param m a numeric number of for controlling mean downshifting.
#' @param s a numeric number of for controlling standard deviation of downshifted sampling values.
#' @export
#'
tailImpute <- function(mat, m=1.6, s=0.6) {
ms <- colMeans(mat, na.rm=TRUE)
sds <- apply(mat, 2, sd, na.rm=TRUE)
mat.impute <- mat
for (i in 1:ncol(mat.impute)) {
r <- rnorm(n=sum(is.na(mat.impute[,i])), mean=(ms[i]-sds[i]*m), sd=(sds[i]*s))
mat.impute[which(is.na(mat.impute[,i])),i] <- r
}
return(mat.impute)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.