STEP ONE: Reading in the Files
A3 <- read.csv('A3_Pierce_Standard_0001_A3_26-07-17_13-30_0002.csv')
C4 <- read.csv('c4_digested20minlycice_0001_C4_26-07-17_15-16_0001.csv')
STEP TWO: Column slice to keep only m/z and intensity
A3new <- A3[,1:2]
C4new <- C4[,1:2]
#any number before the column keeps the associated row, after keeps columns
names(A3new) <- c('m_z','int')
names(C4new) <- c('m_z','int')
STEP THREE: Filtering by m/z and round
A3filtered <- A3new[A3new$int>1000,]
C4filtered <- C4new[C4new$int>100,]
A3filtered$m_z <- round(A3filtered$m_z)
C4filtered$m_z <- round(C4filtered$m_z)
STEP FOUR: Keep all rows of A3 that have similar peak to C4
matchDF <- merge(A3filtered,
C4filtered,by="m_z")
STEP FIVE: Tidy data
A3tidy <- cbind(sample='Standard',A3filtered)
C4tidy <- cbind(sample='Digest', C4filtered)
Matchtidy <- cbind(sample='Match',
matchDF[,c(1,3)])
names(Matchtidy) <- c('sample', 'm_z', 'int')
tidyDF <- rbind(A3tidy,
C4tidy,
Matchtidy)
STEP SIX: Plot using ggplot and facet wrap
ggplot(tidyDF, aes(x = m_z, y = int))+
geom_col(aes(colour = sample, fill = sample))+
xlab("m/z ratio") + ylab("millivolts")+
facet_wrap(~sample,nrow=3)
