#April 2016 # High level function to normalize flat scores matrix w.r.t. MaxNorm or Quantile Normalization (Qnorm) # INPUT: # norm.type: it must be a normalization method: # - MaxNorm: each score is divided w.r.t. the max of each class # - Qnorm: a quantile normalization is applied. Library preprocessCore is used. # flat.file: name of the flat scores matrix (without rda extension). # ann.file: name of the target labels (without rda extension). It must be an .rda file containing the label matrix of the examples (def: ann.file) # dag.file: name of the graph that represents the hierarchy of the classes. # flat.dir: relative path to folder where flat normalized scores matrix is stored # ann.dir: relative path to folder where annotation matrix is stored # dag.dir: relative path to folder where graph is stored # OUTPUT: # the matrix of the scores flat normalized w.r.t. MaxNorm or Qnorm Do.FLAT.scores.normalization <- function( norm.type= "MaxNorm", flat.file=flat.file, ann.file=ann.file, dag.file=dag.file, flat.dir=flat.dir, ann.dir=ann.dir, dag.dir=dag.dir, flat.norm.dir=flat.norm.dir ){ ## Loading Data ############ ## loading hpo dag dag.path <- paste0(dag.dir, dag.file,".rda"); hpo <- get(load(dag.path)); ##root node root <- root.node(hpo); ## loading flat scores matrix relative to a specific subontology flat.path <- paste0(flat.dir, flat.file,".rda"); S.flat <- get(load(flat.path)); gc(); ##in order to save ram memory.. ## removing root node from flat matrix if it exists if(root %in% colnames(S.flat)){ S.flat <- S.flat[,-which(colnames(S.flat)==root)]; } ## loading annotation matrix ann.path <- paste0(ann.dir, ann.file,".rda"); hpo.ann <- get(load(ann.path)); gc(); ## removing root node from annotation table ann.no.root <- target <- hpo.ann[,-which(colnames(hpo.ann)==root)]; ## normalization if(norm.type=="MaxNorm"){ ## Max Normalization S.norm <- normalize.max(S.flat); }else{ ## Quantile Normalization S.norm <- normalize.quantiles(S.flat); dimnames(S.norm) <- list(rownames(S.flat),colnames(S.flat)); } ## Storing results save(S.norm, file=paste0(flat.norm.dir, norm.type, ".", flat.file, ".rda")); }