R/TreeMetaManualRenaming.R

Defines functions TreeMetaManualRenaming

Documented in TreeMetaManualRenaming

#' Selective naming of metaclustesters according to specific markers expression
#'
#' TreeMetaRenaming is a function that allows the automatic renaming of the metaclusters according to their expression for specific markers. If this function is applied, the metaclusters will be renamed for the following commands of the script.
#' @param TreeMetaCl Object generated by the function BuildFSOMTree
#' @param NameDF A data frame with two column: "oldName" and "newName". No identical names in column newName is allowed. Avoid factors.
#' @return BuildFSOMTree object with the metaclusters renamed
#' @export


TreeMetaManualRenaming <- function(TreeMetaCl,NamesDF)
  {
  if ((length(which(names(NamesDF) == "oldName"))  == 1) | (length(which(names(NamesDF) == "newName")) == 1)) {
    NewTreeMetaCl = TreeMetaCl
    if (length(NamesDF$newName) != length(unique(NamesDF$newName))) {stop("Some identical new names")}
    for (index in (1:length(NamesDF[,1]))) {
    NewTreeMetaCl$metaCl[which(TreeMetaCl$metaCl == NamesDF[index,"oldName"])] = as.character(NamesDF[index,"newName"])
    }
    return(NewTreeMetaCl)
  }
  else {stop("Bad name data frame")}
}
gautierstoll/CytoSOM documentation built on May 16, 2020, 10:36 a.m.