Hi,
I'm new to MSnbase package and am trying to plot MS2 spectra with each peaks annotated with their m/z values.
I followed the examples from the MSnbase document as below.
rawdata <- readMSData("filename", msLevel = 2) sp <- rawdata[which.max(peaksCount(rawdata))] plot(sp, full = TRUE)
This gives me a plot of intensity vs. M/Z. I read in the documentation that plot function can annotate fragment ions by matching it to a peptide sequence, but I'm wondering if I can annotate each of these peaks with their M/Z values instead of their IDs, to make sure all peaks that weren't matched to some reference still show their M/Z values. In addition, it would also be useful if I can annotate M/Z values of ten peaks that have highest intensities. I'm aware that I can use mz(rawdata)
to get a list of M/Zs but just wondering if there are ways to plot them using functions supported in the MSnbase package. Any advice would be greatly appreciated!
I initially asked this question because I don't have any sequence information that can be matched to the spectrum, and the code you put as an example (
plot(sp, s, main = s)
) seemed like it specifically required a sequence-like object for it to work. However, your getting the spectrum into a data frame inspired me to come up with what I wanted, so thank you for pointing that out! I'm posting the code I used in case anyone in the future needs this.