Omigami
A package to access Omigami services.
Installation
Omigami supports python 3.7 and 3.8. To install it, simply:
pip install omigami
To be able to visualise the molecule plots, you need to install rdkit
.
For Mac and Linux users, please do:
pip install omigami[plots]
For Windows users, you need to do the following:
conda install -c conda-forge rdkit
Acknowledgement
Spec2Vec
Huber F, Ridder L, Verhoeven S, Spaaks JH, Diblen F, Rogers S, et al. (2021) Spec2Vec: Improved mass spectral similarity scoring through learning of structural relationships. PLoS Comput Biol 17(2): e1008724. https://doi.org/10.1371/journal.pcbi.1008724
MS2DeepScore
Florian Huber, Sven van der Burg, Justin J.J. van der Hooft, Lars Ridder. (2021) MS2DeepScore - a novel deep learning similarity measure for mass fragmentation spectrum comparisons. bioRxiv 2021, doi: https://doi.org/10.1101/2021.04.18.440324
Motivation
Motivation We aim to support metabolomics research by providing the following :
- Easy-to-use tools
- Access and scalability to the newest algorithms
- Maintenance, support and documentation of software, models and data
- A community of metabolomics researchers via our Slack
Features
- Spec2Vec spectra matching
- MS2Deep score
Usage
Spec2Vec
Quickstart
from omigami import Spec2Vec
client = Spec2Vec(token="your_token")
mgf_file_path = "path_to_file.mgf"
n_best_matches = 10
include_metadata = ["Smiles", "Compound_name"]
ion_mode = "positive" # either positive or negative
result = client.match_spectra_from_path(
mgf_file_path, n_best_matches, include_metadata, ion_mode=ion_mode,
)
The supported metadata keys for omigami are (case insensitive):
- "smiles",
- "compound_name",
- "instrument",
- "parent_mass",
- "inchikey_smiles",
- "inchikey_inchi"
Notebooks
You can find a tutorial notebook in the /notebooks/
folder.
MS2DeepScore
Quickstart
from omigami import MS2DeepScore
client = MS2DeepScore(token="your_token")
mgf_file_path = "path_to_file.mgf"
n_best_matches = 10
include_metadata = ["Smiles", "Compound_name"]
ion_mode = "positive" # either positive or negative
result = client.match_spectra_from_path(
mgf_file_path, n_best_matches, include_metadata, ion_mode=ion_mode,
)
Notebooks
You can find a tutorial notebook in the /notebooks/
folder.
Plotting
Plotting graphs works the same way for both Spec2Vec and MS2DeepScore.
The following example will plot the structures of the molecules
from omigami import MoleculePlotter
plotter = MoleculePlotter()
plotter.plot_molecule_structure_grid(best_matches,
draw_indices=True,
molecule_image_size=[600, 600],
substructure_highlight="C(=O)")
The following code allows us to plot the results of the Classyfire model API.
from omigami import MoleculePlotter
plotter = MoleculePlotter()
plotter.plot_classyfire_result(best_matches)
Furthermore, Omigami provides the possibility to use the NPClassifier API.
from omigami import MoleculePlotter
plotter = MoleculePlotter()
plotter.plot_NPclassifier_result(best_matches, color='orange')
How it works
Spec2Vec
- Save your spectra data in a MGF file locally
- Create an Spec2Vec with your user token
- Call
match_spectra_from_path
with the location of your mgf file. - The MGF spectra data will be processed and sent to the spec2vec model that will convert it into embeddings.
- These embeddings will be compared against the reference embeddings around the Precursor MZ.
- The N best matches per spectrum are returned on the response as pandas dataframes.
MS2DeepScore
- Save your pair of spectra data in a MGF file locally
- Create an MS2DeepScore object with your user token
- Call
match_spectra_from_path
with the location of your mgf file. - The MGF spectra data will be processed and sent to the trained neural network that will predict the molecular structural similarity.
- The prediction is returned on the response as a pandas dataframe.
Contribute to Omigami
- Fork it (https://github.com/omigami/omigami/fork)
- Create your feature branch (git checkout -b feature/fooBar)
- Commit your changes (git commit -am 'Add some fooBar')
- Push to the branch (git push origin feature/fooBar)
- Create a new Pull Request
License
MIT license - free software.