f2 <- read.csv('F2.csv', header = FALSE)
f3 <- read.csv('F3.csv', header = FALSE)
f2$V3 <- 'Standard Digest'
f3$V3 <- 'Experimental Digest'
f2 <- f2[,1:3]
f3 <- f3[,1:3]
ms_data <- rbind(f2,f3)
names(ms_data) <-c('mz','intensity','sample')
#create a basic scatter plot with points
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
ggplot(ms_data, aes(x=mz, y=intensity))+
geom_point(aes(colour = sample))+
scale_colour_manual(values=c("#fdc400", "#1957fb"))+
xlab("m/z ratio")+ylab("Millivolts")+
labs(fill="sample")+
theme(legend.position = "left")
#create a column plot to compare samples
ggplot(ms_data, aes(x=mz, y=intensity))+
geom_col(aes(colour = sample, fill=sample))+
scale_color_manual(values=c("#fdc400", "#1957fb"))+
scale_fill_manual(values=c("#fdc400", "#1957fb"))+
xlab("m/z ratio")+ylab("Millivolts")+
theme(legend.position = "right")
#find peaks with identical m/z
matchSpectra <- merge(f2,f3, by="V1")
write.csv(matchSpectra, "matchSpectra.csv")