R/TreeMetaRenaming.R

Defines functions TreeMetaRenaming

Documented in TreeMetaRenaming

#' Automatic naming of metaclustesters according to specific markers expression
#'
#'A name based of markers level is added to the metcluster names (of number, in that case, the numbers are kept in the object as $metaClNumber)
#' @param TreeMetaCl Object generated by the function BuildFSOMTree
#' @param Markers vector of markers used for naming
#' @param Levels number of level for naming: 2 -> -/+ (1/2-4 quartiles), 3-> -/low/high (1/2-3/4 quartiles), 4-> -/low/int/high (1/2/3/4 quartiles)
#' @param CutOff matrix for optional cut off values for naming, with markers in row.names, each column for separating levels. If a marker is not in row.names, quartiles are used
#' @param Short is true, low is not represented with Levels=3, int is not represented if Levels = 4
#' @return BuildFSOMTree object with the metaclusters renamed with the choosen name type, keeping the metacluster numbers ($metaClNumber)
#' @examples CytoTreeNewNames <- TreeMetaRenaming(TreeMetaCl=CytoTree,Markers=c("CD4","CD8","FoxP3"),Levels=4)
#' @export


TreeMetaRenaming<-function(TreeMetaCl,Markers,Levels,CutOff=NULL,Short=FALSE){
  if (is.null(TreeMetaCl$gatingName)) {gName = ""} else
  {gName=TreeMetaCl$gatingName}
  Namings=MetaClusterNaming(TreeMetaCl,Markers,Levels,CutOff,Short)
  if (is.numeric(TreeMetaCl$metaCl)) {TreeMetaCl$metaClNumber = TreeMetaCl$metaCl}
  TreeMetaCl$metaCl = sapply(TreeMetaCl$metaCl,function(x){paste(Namings$oldName[which(Namings$oldName == x)],
                                                                 Namings$newName[which(Namings$oldName == x)],sep="_")})
  return(TreeMetaCl)
  }
gautierstoll/CytoSOM documentation built on May 16, 2020, 10:36 a.m.