Import data that was saved as ASCII in Shimadzu software

d2 <- read.csv('D2.csv', header=FALSE)
d3 <- read.csv('D3.csv', header=FALSE)
d2$V3 <- 'Standard Digest'
d3$V3 <- 'Experimental Digest'
d2 <- d2[,1:3]
d3 <- d3[,1:3]
ms_data <- rbind(d2,d3)
names(ms_data)<-c('mz','intensity','Sample')

#Create basic scatter plot with points

ggplot(ms_data, aes(x = mz,y=intensity))+
  geom_point(aes(colour = Sample))+
  scale_color_manual(values=c("#ffc868","#e5216b"))+
  xlab("m/z ratio") + ylab("Millivolts")+
  theme(legend.position="left")

#Create 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("#ffc868","#e5216b"))+
  scale_fill_manual(values=c("#ffc868","#e5216b"))+
  xlab("m/z ratio") + ylab("Millivolts")+
  theme(legend.position="right")

#Find peaks with identical m/z

matchSpectra <- merge(d2,d3, by="V1")
write.csv(matchSpectra,"matchSpectra.csv")