xcms icon indicating copy to clipboard operation
xcms copied to clipboard

Visualize, use plotSpectraMirror function to draw spectrum matching results

Open v-v1150n opened this issue 9 months ago • 2 comments

I have now completed the Spectra match and got the results. Now I want to use the plotSpectraMirror function to plot all these compounds, but I am not sure how to check that these matched spectra correspond to the two msps file. The index value of the file content. Is there any way I can find the respective index value? The following is the content of my file

> summary(sample_msp)
 Length   Class    Mode 
    373 Spectra      S4 

> summary(mona_spec_libno)
 Length   Class    Mode 
  18915 Spectra      S4 

> mtch_mona
Object of class MatchedSpectra 
Total number of matches: 7 
Number of query objects: 373 (7 matched)
Number of target objects: 18915 (2 matched)

v-v1150n avatar May 06 '24 03:05 v-v1150n

I think I have found a way to search out the index values ​​of the two compared spectra, but when I use plotSpectraMirror to match the two spectra, I find that my graph cannot be compared up and down. Is there any way can be solved? Here are my image results Top: My profile Center: Spectra library Bottom: match results image

v-v1150n avatar May 06 '24 06:05 v-v1150n

To create a mirror plot for one particular query spectrum you can use: plotSpectraMirror(mtch_mona[1]) i.e. select the query spectra for which to plot the results by subsetting the matching result with its respective index. The order is the same as in the original Spectra you provided to the matchSpectra() function with the query parameter.

Generally, I would suggest to add a specific spectra variable to the query Spectra with the index of the spectrum in the original object. that will make it easier to later refer/get back to the original spectrum. The matchSpectra() function from the current Bioconductor release does this automatically. With that you could use matchedData() to extract the information of the matching query and target spectra, get their index or identifier in the respective Spectra object and then create the mirror plot directly on those, e.g.

a # would be the index of a query spectrum
b # would be the index of the matched target spectrum
plotSpectraMirror(sample_msp[a], mona_spec_libno[b])

For your question regarding the difference in intensity: I would suggest to scale the intensities of the query and target spectra before plotting (or even before the matchSpectra() call - although the similarity score functions we use are independent of the absolute intensity values):

sample_msp <- scalePeaks(sample_msp, by = sum)
mona_spec_libno <- scalePeaks(mona_spec_libno, by = sum)

which will scale the intensities to a total sum of one per spectrum.

jorainer avatar May 10 '24 09:05 jorainer