R/plot_labelingefficiency.R

#' Plot TMT labeling efficiency
#'
#' \code{plot_labelingefficiency} generates a stacked barplot for peptides
#' modified by TMT at the N-termini and Lys residues.
#'
#' @param evidencedata Data.frame,
#' evidence table originating from MaxQuant.
#' @examples
#' if(interactive()){
#' data("evidence.raw")
#' evidencedata <- evidence.raw
#' plot_labelingefficiency(evidencedata)
#' }
#' @return A scatter plot (generated by \code{\link[ggplot2]{ggplot}})
#' @import dplyr
#' @import ggplot2
#' @export
plot_labelingefficiency <-  function (evidencedata) {
  plot<-
    evidencedata  %>%
    count(Modifications) %>%
    mutate(Modifications=case_when(
      Modifications=="Unmodified"~"Unmodified",TRUE~"TMT Modified")) %>%
    count(Modifications, wt=n ) %>%
    mutate(freq = n / sum(n)) %>%
    dplyr::mutate(g="Peptides") %>%
    ggplot(aes(x = factor(g), y = freq*100, fill = factor(Modifications))) +
    geom_bar(stat="identity", width = 0.7) +
    labs(x = "", y = "Percentage (%)", fill = "Type") +
    theme_minimal(base_size = 14)
  return(plot)
}
demar01/protrusionproteome documentation built on April 29, 2021, 5:47 a.m.