Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize, use plotSpectraMirror function to draw spectrum matching results #744

Open
v-v1150n opened this issue May 6, 2024 · 2 comments

Comments

@v-v1150n
Copy link

v-v1150n commented May 6, 2024

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
Copy link
Author

v-v1150n commented May 6, 2024

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

@jorainer
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants