#' Plot protease misscleavage rate
#'
#' \code{plot_miscleavagerate} generates a stacked barplot for protease miss
#' cleavage rate.
#'
#' @param peptides Data.frame,
#' Peptide table originating from MaxQuant.
#' @return A scatter plot (generated by \code{\link[ggplot2]{ggplot}})
#' @examples
#' if(interactive()){
#' data("peptides.raw")
#' pepdata <- peptides.raw
#' plot_miscleavagerate(pepdata)
#' }
#' @import dplyr
#' @importFrom dplyr select
#' @import ggplot2
#' @export
plot_miscleavagerate <- function (peptides) {
peptides %>% as_tibble() %>%
group_by( Missed.cleavages) %>%
summarise(n = n()) %>%
mutate(freq = n / sum(n)) %>%
mutate(g="Missed.cleavages") %>%
ggplot(aes(x = factor(g), y = freq*100, fill = factor(Missed.cleavages))) +
geom_bar(stat="identity", width = 0.7) +
labs(x = "", y = "Percentage (%)", fill = "Number") +
theme_minimal(base_size = 14)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.