R/get_names.R

Defines functions get_names

Documented in get_names

#' Get names of each sample and group names
#' @author Simon J Pelletier
#' @param x Matrix or vector
#' column name has to be separeted
#' @return The name of each groups.
#' @examples
#' expr.matrix <- readRDS("data/expr_matrix_LGVD.rds")
#' @keywords names names.unique
#' @export
get_names = function(x){
  if (is.matrix(x)) names <- colnames(expr.matrix)
  else names <- x
  names1 = rep("",length(names))
  for (i in 1:length(names)){
    nameSplit = strsplit(names[i],"_")
    for (j in 1:(length(nameSplit[[1]]))){
      if(j==1) names1[i] = nameSplit[[1]][j]
      else if(length(grep("([0-9]+).*$", nameSplit[[1]][j])) == 0) names1[i] = paste0(names1[i],"_",nameSplit[[1]][j])
    }
  }
  return(names1)
}
spell098/rnaseq_app documentation built on May 30, 2019, 7:57 a.m.