#' Renormalize the BMDK features data
#'
#' After outliers are removed, renormalize the features data and store the
#' new max value of each feature.
#'
#' @param dat a list containing 4 elements: case, a list of case/control statuses;
#' feat, a matrix of normalized feature data; maxfeat, a list of max features
#' from each column in feat; minfeat, a list of min features for each feature
#' @return List containing 4 elements (case, feat, maxfeat, minfeat)
#' renormalized after outliers are removed
renormalize_bmdk <- function(dat)
{
# After removing outliers, unnormalize dat
dat$feat <- t(t(dat$feat) * (dat$maxfeat - dat$minfeat) + dat$minfeat)
# Reevaluate the max feature of each column
dat$maxfeat <- apply(dat$feat, 2, max)
# Reevaluate the min feature of each column
dat$minfeat <- apply(dat$feat, 2, min)
# Renormalize dat
dat$feat <- apply(dat$feat, 2,
function(.x){(.x - min(.x, na.rm = TRUE)) /
(max(.x, na.rm = TRUE) - min(.x, na.rm = TRUE))})
return(dat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.