#' A function that takes a protein dataframe and ptm data frame.
#'
#' This function will allow you to count the number of PTMs in a protein data frame generated by the fetchGenebank function. It will use the data from the PTM dataframe
#' created by the PTM function. Using the geneid it will link the data and count the PTMs.
#'
#'
#' @param proteindf Data frame of protein data generated by the fetchGenebank function.
#' @param ptmdf Data frame of PTM data generated by the ptm function
#' @keywords Proteins, PTMS
#' @export
#' @examples
#'
#' proteindf <- countPTMs(proteindf, ptmdf)
countPTMs <- function(proteindf, ptmdf){
PTMchange <- data.frame(PTMs = unique(conversion$New), PTMweightchange = unique(conversion$Weight))
PTMchange <- subset(PTMchange, PTMchange$PTMs %in% ptmdf$type )
proteindf$Len <-nchar(proteindf$seq)
df1 <- ddply(proteindf, .(geneid), transform, start=sapply(seq, function(x) regexpr(x, seq[which.max(Len)])))
for(i in 1:length(df1$seq)){
df1$stop[i] <- df1$start[i] + df1$Len[i] - 1
}
df2 <- cbind(df1, setNames( lapply(PTMchange$PTMs, function(x) x=NA), PTMchange$PTMs) )
df2[is.na(df2)]<-0
colnames(ptmdf)[1] <- 'geneid'
for(i in 1:length(df2$protienName)){
for(j in 1:length(ptmdf$geneid)){
if(df2$geneid[i] == ptmdf$geneid[j] & ptmdf$start[j] %in% df2$start[i]:df2$stop[i] & ptmdf$end[j] %in% df2$start[i]:df2$stop[i]){
df2[ptmdf$type[j]][i,] <- df2[ptmdf$type[j]][i,] + 1
}
}
}
return(df2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.