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

Missing SpectrumBinner #216

Open
asmirn1 opened this issue May 10, 2024 · 8 comments
Open

Missing SpectrumBinner #216

asmirn1 opened this issue May 10, 2024 · 8 comments

Comments

@asmirn1
Copy link

asmirn1 commented May 10, 2024

Hi,

I'm trying to follow this notebook to learn more about ms2deepscore. However, I'm getting the error

ImportError                               Traceback (most recent call last)
Cell In[9], line 1
----> 1 from ms2deepscore import SpectrumBinner
      2 spectrum_binner = SpectrumBinner(10000, mz_min=10.0, mz_max=1000.0, peak_scaling=0.5, allowed_missing_percentage=100.0)
      3 binned_spectra = spectrum_binner.fit_transform(spectra)

ImportError: cannot import name 'SpectrumBinner' from 'ms2deepscore'

I looked at the source code and couldn't find SpectrumBinner. Does the code below looks right to you:

from ms2deepscore import SpectrumBinner
spectrum_binner = SpectrumBinner(10000, mz_min=10.0, mz_max=1000.0, peak_scaling=0.5, allowed_missing_percentage=100.0)
binned_spectra = spectrum_binner.fit_transform(spectra)

Thank you!

@niekdejonge
Copy link
Collaborator

Hi asmirn1 we updated our code quite a bit recently, but we did not have the time yet to update this. We should remove or update this tutorial.
The readme should be up to date and should have the information you need to get it to work. Let me know if there is anything unclear or not working from the readme.

@asmirn1
Copy link
Author

asmirn1 commented May 14, 2024

@niekdejonge

I'm trying to convert each MS/MS spectrum into a vector. I only need a vector, without calculating similarity scores. I couldn't find it in the examples on the readme file. The closest thing that I could find is in this tutorial

Could you tell me how to convert MS/MS spectra into vectors in the new version of the code?

@niekdejonge
Copy link
Collaborator

Ah yes, you are right, that is missing. Below the code to create embedding/vector representations.

model = load_model(model_file_name)
ms2ds_model = MS2DeepScore(model)
ms2ds_embeddings = ms2ds_model.get_embedding_array(spectra_cleaned_for_ms2deepscore)

I recently gave a workshop with a tutorial for MS2Deepscore for the current version, I will soon clean it up and upload it as well, but didn't find the time yet.

@asmirn1
Copy link
Author

asmirn1 commented May 22, 2024

@niekdejonge Thank you for the example!

I've tried

from ms2deepscore import MS2DeepScore
from ms2deepscore.models import load_model

model = load_model("ms2deepscore_model.pt")
ms2ds_model = MS2DeepScore(model)
ms2ds_embeddings = ms2ds_model.get_embedding_array(spectra)

But I've got a warning: "The model version (0.5.0) does not match the version of MS2Deepscore (2.0.0), consider downloading a new model or changing the MS2Deepscore version"

Also, I've got an error:
Screenshot 2024-05-22 164809

I downloaded the file ms2deepscore_model.pt from Zenodo, but it seems to be too old. Is there a newer model that I can download, or should I switch to an older version of ms2deepscore?

@justinjjvanderhooft
Copy link

Hi, we have recently posted a preprint on MS2DeepScore 2.0, see https://www.biorxiv.org/content/10.1101/2024.03.25.586580v2, and the accompanying model can be found here: https://zenodo.org/records/10814307. Given that it was trained on updated and curated data as compared to earlier versions, I would advise to try this one.

@niekdejonge
Copy link
Collaborator

@asmirn1 The issue you have here is that your spectra don't have the ionmode specified. Since MS2Deepscore 2.0 uses the ionmode to make a prediciton the model will not run. If you know the ionmode you could for instance add the ionmode using matchms (or manually adding it to the file)

@AharoniLab
Copy link

Hi,

I want to add that since this issue was opened a couple of months ago the tutorial / procedure to train MS2DeepScore 2.0 doesn't seem to have been updated or replaced by a more current one and in addition there are quite confusing code bits instructing to train the first version model (PI mode only) and some wrapper functions for training and it's all quite confusing. So:

  1. If ms2deepscore.SpectrumBinner is essential for preparing the training data - where is it implemented and why doesn't it simply load with the package?
  2. A data-prep. wrapper which takes a spectra file with specified meta data fields and prepares all objects or files needed for training the V2 model(s) would be very helpful at this point.

Thanks, Nir.

@AharoniLab
Copy link

Ah yes, you are right, that is missing. Below the code to create embedding/vector representations.

model = load_model(model_file_name)
ms2ds_model = MS2DeepScore(model)
ms2ds_embeddings = ms2ds_model.get_embedding_array(spectra_cleaned_for_ms2deepscore)

I recently gave a workshop with a tutorial for MS2Deepscore for the current version, I will soon clean it up and upload it as well, but didn't find the time yet.

Do you per chance have a recording or documentation from that workshop?

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

4 participants