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

MatchSpectra function #52

Open
tiwa1125 opened this issue Jan 5, 2022 · 5 comments
Open

MatchSpectra function #52

tiwa1125 opened this issue Jan 5, 2022 · 5 comments

Comments

@tiwa1125
Copy link

tiwa1125 commented Jan 5, 2022

Hi,
I tried to use the MetaboAnnotation to annotate my metabolites, and I used the HMDB to get the match, while when I used the code below, I even did not get any matches, that is weird, as I am sure there are many metabolites could be identified. Do you know what is the problem?

data("hmdb", package = "SpectraTutorials")
mtches <- matchSpectra(pest_ms2, hmdb,
param = CompareSpectraParam(requirePrecursor = TRUE, ppm = 30))
mtches
Object of class MatchedSpectra
Total number of matches: 0
Number of query objects: 5220 (0 matched)
Number of target objects: 458963 (0 matched)

Best
Tingting

@jorainer
Copy link
Member

jorainer commented Jan 5, 2022

I assume the pest_ms2 contains MS2 spectra from the pesticide test data? If that's the case you'll not find matches in HMDB because HMDB provides human metabolite data and does not contain (AFAIK) plant pesticides You should however get some matches if you use MassBank as that resource contains also MS2 spectra from not naturally occuring compounds.

@tiwa1125
Copy link
Author

tiwa1125 commented Jan 5, 2022 via email

@jorainer
Copy link
Member

jorainer commented Jan 6, 2022

I would maybe suggest to remove some of the low intensity peaks in your MS2 spectra (similar to what I did in the tutorial). Then, importantly, HMDB does not provide precursor m/z values, so you should use requirePrecursor = FALSE. Unfortunately, this will have a huge impact on performance because then you'll compare all your experimental spectra with all database spectra. Maybe it would also be helpful to subset the HMDB data excluding predicted spectra (using hmdb <- hmdb[!hmdb$predicted])?

If you still miss some of the obvious hits, it might be that you have to further increase the ppm or tolerance. Some of the spectra in HMDB seem to be mis-calibrated (I had to use a large tolerance value to find some of our pure standards in HMDB data).

@tiwa1125
Copy link
Author

tiwa1125 commented Jan 19, 2022 via email

@jorainer
Copy link
Member

Note that the masses of the compounds are exact masses, not m/z values, thus, they might indeed be smaller than the precursor ion, depending on what ion/adduct was fragmented. Hm, and you're right, the compound name is not available in that data.

I would thus suggest to do something different:

  • Install the CompoundDb package with BiocManager::install("RforMassSpectrometry/CompoundDb").
  • Download the CompDb database for HMDB (5.0 from 2021-11-02) from here (i.e. download the .sqlite file to your computer).
  • Use that database instead of the hmdb variable you use above.

Basically, in your script, replacing

data("hmdb", package = "SpectraTutorials")

with

library(CompoundDb)
cdb <- CompDb(<sqlite file name>)
hmdb <- Spectra(cdb)

(<sqlite file name> would then be the path and filename of the downloaded sqlite file) should allow you to use this resource instead. You could also have a look at this new tutorial for the MetaboAnnotation package for more information.

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