R/tidy_mat.R

Defines functions tidy_mat

Documented in tidy_mat

#' Removes duplicated rows in the matrices and rows with "NA" inside.
#' @description Takes list with matrices passed by "plot_hm"-function and removes duplicated rows and rows with "NA" inside. Called by "plot_hm"-function.
#' @param ugmat A list with matrices and additional information about the selected region. mat generated by "get_matrix"-function, passed by "plot_hm"-function. Default value is NULL.
#' @return list with cleaned matrices and additional information about the region entered in "get_matrix"-function. Will be used of "plot_hm"-function

########## removes duplicated rows in the matrices and rows with "NA" inside ##########
###called by plot_hm function
tidy_mat = function(ugmat = NULL){
 
  if(is.null(ugmat)){
    stop("no ugmat available")
  }
  
  nmats = length(ugmat)-5
  for(i in 1:nmats){
    ugmat[[i]] = ugmat[[i]][!duplicated(ugmat[[i]]), ]
    ugmat[[i]]=na.omit(ugmat[[i]])
  }
  return(ugmat)
}
ClaudiaRHD/chipAnalyser documentation built on June 18, 2020, 8:31 p.m.