knitr::opts_chunk$set(echo = TRUE,message=FALSE, warning=FALSE)
library(dplyr) library(knitr) library(mzR) library(MSnbase) remote_dir=file.path("https://raw.githubusercontent.com/PacktPublishing", "R-Bioinformatics-Cookbook/master/datasets/ch6")
library(MSnID) library(data.table) library(dplyr) library(ggplot2) msnid_file <- "HeLa_180123_m43_r2_CAM.mzid.gz" if (!file.exists(msnid_file)) { download.file(file.path(remote_dir,msnid_file), msnid_file) } msnid <- MSnID() msnid <- read_mzIDs(msnid, msnid_file) peptide_info <- as(msnid, "data.table")
per_peptide_counts <- peptide_info %>% filter(isDecoy == FALSE) %>% group_by(pepSeq) %>% summarise(count = n() ) %>% mutate(sample = rep("peptide_counts", length(counts) ) ) ## 3. Create a violin and jitter plot of the hit counts: g <- per_peptide_counts %>% ggplot() + aes( sample, count) + geom_jitter() + geom_violin() + scale_y_log10()
print(g)
g2 <- per_peptide_counts %>% arrange(count) %>% mutate(cumulative_hits = cumsum(count), peptide = 1:length(count)) %>% ggplot() + aes(peptide, cumulative_hits) + geom_line()
print(g2)
filtered_per_peptide_counts <- per_peptide_counts %>% filter(count >= 5, count <= 2500) g3 <- filtered_per_peptide_counts %>% ggplot() + aes( sample, count) + geom_jitter() + geom_violin() + scale_y_log10()
print(g3)
library(mzR) mzxml_file <- "threonine_i2_e35_pH_tree.mzXML" if (!file.exists(mzxml_file)) { download.file(file.path(remote_dir, mzxml_file), mzxml_file) } mzdata <- openMSfile(mzxml_file) # file "threonine_i2_e35_pH_tree.mzXML"
header_info <- header(mzdata) peak_data_list <- spectra(mzdata)
writeMSData(peak_data_list, file.path(remote_dir, "out.mz"), header = header_info, outformat = "mzml", rtime_seconds = TRUE)
library(mzR) library(protViz) mzml_file <- "MM8.mzML" # was downloaded earlier ms <- openMSfile(mzml_file)
p <- peaks(ms,2) spec <- list(mZ = p[,1], intensity = p[,2])
df <- data.frame(cbind(mZ=spec$mZ, intensity=spec$intensity)) df %>% ggplot(aes(x=mZ, y=intensity)) + geom_line()
m <- psm("PEPTIDESEQ", spec, plot=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.