R/MQ_summary_MS2_id.R

#'Number of MS2 spectra identified (read from MaxQuant summary.txt)
#'
#'@description Reads MaxQuant summary.txt output file and plots the number of
#'    MS2 spectra identified Use the `add_groups` function first to add groups based
#'    on the experiment name, and color the different raw files based on the groups.
#'
#'@param x The processed summary.txt output file
#'@param grouping Default value is FALSE. If set to true, the different experiments
#'    will be colored based on the `my_groups` column. Use \code{\link{add_groups}} function
#'    to define the groups based on experiment names.
#'
#'@export
MQ_summary_MS2_id <- function(x, grouping = FALSE){
  if (grouping == TRUE) {
    p <- ggplot(x, aes(Experiment, MS.MS.Identified , fill = my_groups))
  } else {
    p <- ggplot(x, aes(Experiment, MS.MS.Identified))
  }
  p <- p + geom_bar(stat = "identity", position = "dodge")
  p <- p + geom_text(aes(label = MS.MS.Identified), vjust = -0.25)
  p <- p + theme_bw()
  p <- p + xlab("Sample")
  p <- p + ylab("Number of MS2 spectra")
  p <- p + ggtitle("Number of MS2 spectra identified per experiment.")
  p <- p + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))
  p <- p + theme(legend.position = "bottom")
  p <- p + theme(legend.key.size = unit(0.2, "cm"))
  p <- p + theme(legend.text = element_text(size = 8))
  print(p)
}
tkostas/viewMQ documentation built on May 6, 2019, 6:02 p.m.