R/ptmClean.R

Defines functions ptmClean

Documented in ptmClean

#' A function that takes a data frame of PTM modifications created by the PTM function. 
#' 
#' This function will allow you to enter a list of dataframe of PTM data. It will remove spaces and normalize the names for the PTMs. It will also subset the ptmdf,
#' so that it only includes PTMs that are in your dataset.
#' 
#' 
#' @param ptmdf Dataframe of PTM data generated by the PTM function. 
#' @keywords UNIPROT, PTMS, protiens, data cleaning
#' @export
#' @examples
#'
#' ptmdf <- ptmClean(ptmdf)


ptmClean <- function(ptmdf){
  conversion$Old <- trimws(conversion$Old, which = c("both", "left", "right"))
  
  ptmdf$type <- as.character(ptmdf$type)
  conversion$Old<- as.character(conversion$Old)
  conversion$New <- as.character(conversion$New)
  
  for(i in 1:length(ptmdf$type)){
    for(j in 1:length(conversion$Old)){
      if(ptmdf$type[i] == conversion$Old[j]){
        ptmdf$type[i] <- conversion$New[j]
      }
    }
  }
  
  ptmdf$type <- trimws(ptmdf$type, which = c("both", "left", "right"))
  
  rem <- ptmdf$type %in% conversion$New
  ptmdf <- subset(ptmdf, rem)
  
  
  
  return(ptmdf)
}
hawkdidy/prodata documentation built on May 17, 2019, 3:06 p.m.