From 64ada8d22c1551f96a6e9b2985362722802500e1 Mon Sep 17 00:00:00 2001 From: rodvrees Date: Fri, 19 Jul 2024 02:23:35 +0200 Subject: [PATCH 1/6] ionmob performance scatterplot --- ms2rescore/report/generate.py | 30 +++++++++++++++++++++++++- ms2rescore/report/templates/texts.toml | 6 ++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ms2rescore/report/generate.py b/ms2rescore/report/generate.py index 91444bfe..1f399219 100644 --- a/ms2rescore/report/generate.py +++ b/ms2rescore/report/generate.py @@ -351,7 +351,7 @@ def _get_features_context( observed_column="ccs_observed_im2deep", xaxis_label="Observed CCS", yaxis_label="Predicted CCS", - plot_title="Predicted vs. observed CCS", + plot_title="Predicted vs. observed CCS - IM2Deep", ) context["charts"].append( @@ -361,6 +361,34 @@ def _get_features_context( "chart": scatter_chart.to_html(**PLOTLY_HTML_KWARGS), } ) + + # ionmob specific charts + if "ionmob" in feature_names: + try: + import deeplc.plot + + scatter_chart = deeplc.plot.scatter( + df=features[(~psm_list["is_decoy"]) & (psm_list["qvalue"] <= 0.01)], + predicted_column="ccs_predicted", + observed_column="ccs_observed", + xaxis_label="Observed CCS", + yaxis_label="Predicted CCS", + plot_title="Predicted vs. observed CCS - ionmob", + ) + + context["charts"].append( + { + "title": TEXTS["charts"]["ionmob_performance"]["title"], + "description": TEXTS["charts"]["ionmob_performance"]["description"], + "chart": scatter_chart.to_html(**PLOTLY_HTML_KWARGS), + } + ) + + # TODO: for now, ionmob plot will only be available if deeplc is installed. Since ionmob does not have a dependency on deeplc, this should be changed in the future. + except ImportError: + logger.warning( + "Could not import deeplc.plot, skipping ionmob CCS prediction performance plot. Please install DeepLC to generate this plot." + ) return context diff --git a/ms2rescore/report/templates/texts.toml b/ms2rescore/report/templates/texts.toml index 52c9a230..ff4ec5b4 100644 --- a/ms2rescore/report/templates/texts.toml +++ b/ms2rescore/report/templates/texts.toml @@ -111,3 +111,9 @@ title = "IM2Deep model performance" description = """ IM2Deep model performance can be visualized by plotting the predicted CCS against the observed CCS. """ + +[charts.ionmob_performance] +title = "ionmob model performance" +description = """ +ionmob model performance can be visualized by plotting the predicted CCS against the observed CCS. +""" From dd1e9d81ad778b4b98169652814d3bdeb0882af1 Mon Sep 17 00:00:00 2001 From: ArthurDeclercq Date: Thu, 18 Jul 2024 18:50:08 +0200 Subject: [PATCH 2/6] parse_psms bug fix --- ms2rescore/parse_psms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ms2rescore/parse_psms.py b/ms2rescore/parse_psms.py index 12edd0e9..6a3c6065 100644 --- a/ms2rescore/parse_psms.py +++ b/ms2rescore/parse_psms.py @@ -47,7 +47,9 @@ def parse_psms(config: Dict, psm_list: Union[PSMList, None]) -> PSMList: _calculate_qvalues(psm_list, config["lower_score_is_better"]) if config["psm_id_rt_pattern"] or config["psm_id_im_pattern"]: logger.debug("Parsing retention time and/or ion mobility from PSM identifier...") - _parse_values_from_spectrum_id(config, psm_list) + _parse_values_from_spectrum_id( + psm_list, config["psm_id_rt_pattern"], config["psm_id_im_pattern"] + ) # Store scoring values for comparison later for psm in psm_list: @@ -165,9 +167,7 @@ def _parse_values_from_spectrum_id( ["retention_time", "ion_mobility"], ): if pattern: - logger.debug( - f"Parsing {label} from spectrum_id with regex pattern " f"{psm_id_rt_pattern}" - ) + logger.debug(f"Parsing {label} from spectrum_id with regex pattern " f"{pattern}") try: pattern = re.compile(pattern) psm_list[key] = [ From 2c6bfcb2ed78c88dc67168d09e6e726139864ae0 Mon Sep 17 00:00:00 2001 From: RalfG Date: Wed, 17 Jul 2024 17:25:36 +0200 Subject: [PATCH 3/6] Update tims2rescore documentation --- README.md | 19 ++++++- docs/source/userguide/configuration.rst | 13 +++++ docs/source/userguide/tims2Rescore.rst | 69 +++++++++++++++---------- ms2rescore/__main__.py | 18 ++++--- 4 files changed, 85 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index bf48b060..c6d6b71a 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,17 @@ files: MS²Rescore is available as a [desktop application][desktop], a [command line tool][cli], and a [modular Python API][python-package]. +## TIMS²Rescore: Direct support for DDA-PASEF data + +MS²Rescore v3.1+ includes TIMS²Rescore, a usage mode with specialized default configurations for +DDA-PASEF data from timsTOF instruments. TIMS²Rescore makes use of new MS²PIP prediction models for +timsTOF fragmentation and IM2Deep for ion mobility separation. Bruker .d and miniTDF spectrum +files are directly supported through the [timsrust](https://github.com/MannLabs/timsrust) library. + +Checkout our [preprint](https://doi.org/10.1101/2024.05.29.596400) for more information and the +[TIMS²Rescore documentation](https://ms2rescore.readthedocs.io/userguide/tims2rescore) +to get started. + ## Citing **Latest MS²Rescore publication:** @@ -54,10 +65,16 @@ MS²Rescore is available as a [desktop application][desktop], a [command line to **MS²Rescore for immunopeptidomics:** -> **MS2Rescore: Data-driven rescoring dramatically boosts immunopeptide identification rates.** +> **MS²Rescore: Data-driven rescoring dramatically boosts immunopeptide identification rates.** > Arthur Declercq, Robbin Bouwmeester, Aurélie Hirschler, Christine Carapito, Sven Degroeve, Lennart Martens, and Ralf Gabriels. > _Molecular & Cellular Proteomics_ (2021) [doi:10.1016/j.mcpro.2022.100266](https://doi.org/10.1016/j.mcpro.2022.100266) +**MS²Rescore for timsTOF DDA-PASEF data:** + +> **TIMS²Rescore: A DDA-PASEF optimized data-driven rescoring pipeline based on MS²Rescore.** +> Arthur Declercq*, Robbe Devreese*, Jonas Scheid, Caroline Jachmann, Tim Van Den Bossche, Annica Preikschat, David Gomez-Zepeda, Jeewan Babu Rijal, Aurélie Hirschler, Jonathan R Krieger, Tharan Srikumar, George Rosenberger, Dennis Trede, Christine Carapito, Stefan Tenzer, Juliane S Walz, Sven Degroeve, Robbin Bouwmeester, Lennart Martens, and Ralf Gabriels. +> _bioRxiv_ (2024) [doi:10.1101/2024.05.29.596400](https://doi.org/10.1101/2024.05.29.596400) + **Original publication describing the concept of rescoring with predicted spectra:** > **Accurate peptide fragmentation predictions allow data driven approaches to replace and improve upon proteomics search engine scoring functions.** diff --git a/docs/source/userguide/configuration.rst b/docs/source/userguide/configuration.rst index e22b3ec1..a692f774 100644 --- a/docs/source/userguide/configuration.rst +++ b/docs/source/userguide/configuration.rst @@ -81,6 +81,19 @@ preferably provide the formula instead of a mass shift, as the mass shift can al be calculated from the formula, but not vice-versa, and some feature generators (such as DeepLC) require the modification formula. +.. role:: raw-html(raw) + :format: html + +Formula modification labels can be defined with the ``Formula:`` prefix, followed by each atom +symbol and its count, denoting which atoms are added or removed by the modification. If no count is +provided, it is assumed to be 1. For example, ``Formula:HO3P`` is equivalent to ``Formula:H1O3P1``. +For isotopes, prefix the atom symbol with the isotope number and place the entire block (isotope +number, atom symbol, and number of atoms) in square brackets. For example, the SILAC 13C(2) 15N(1) +label (`UNIMOD:2088 `_) +would be notated as ``Formula:C-2[13C2]N-1[15N]``, meaning that two C atoms are removed, two +:raw-html:`13C` atoms are added, one N atom is removed and one +:raw-html:`15N` atom is added. + And example of the :py:obj:`modification_mapping` could be: .. tab:: JSON diff --git a/docs/source/userguide/tims2Rescore.rst b/docs/source/userguide/tims2Rescore.rst index f9b9096f..51a18b1d 100644 --- a/docs/source/userguide/tims2Rescore.rst +++ b/docs/source/userguide/tims2Rescore.rst @@ -1,61 +1,76 @@ -.. _timsrescore: +.. _tims2rescore: -TIMS²Rescore User Guide -======================= +TIMS²Rescore +============ Introduction ------------ -The `TIMS²Rescore` tool is a DDA-PASEF adapted version of `ms2rescore` that allows users to perform rescoring of peptide-spectrum matches (PSMs) acquired on Bruker instruments. This guide provides an overview of how to use `timsrescore` in `ms2rescore` effectively. +`TIMS²Rescore` is a specialized version of `MS²Rescore` for timsTOF DDA-PASEF data. This guide +provides an overview of how to use TIMS²Rescore effectively. -Installation ------------- - -Before using `timsrescore`, ensure that you have `ms2rescore` installed on your system. You can install `ms2rescore` using the following command: - -.. code-block:: bash +Installing TIMS²Rescore +----------------------- - pip install ms2rescore +TIMS²Rescore is part of the ``ms2rescore`` package. Check out the :ref:`installation` instructions +to get started. Usage ----- -To use `timsrescore`, follow these steps: +To use TIMS²Rescore, follow these steps: 1. Prepare your input files: - - Ensure that you have the necessary input files, including the PSM file spectrum files - - Make sure that the PSM file format from a supported search engine or a standard format like .mzid(:external+psm_utils:ref:`supported file formats `). - - Spectrum files can directly be given as .d or minitdf files from Bruker instruments or first converted to .mzML format. - -2. Run `timsrescore`: + - To boost DDA-PASEF peptide identifications, TIMS²Rescore requires the spectrum files from + the timsTOF instrument and the PSM files with identifications from a supported search engine. + - Make sure that the PSM file format comes from a supported search engine or is a standard + format such as mzIdentML (See + :external+psm_utils:ref:`supported file formats `). + - Spectrum files can directly be passed as ``.d`` or `miniTDF` raw data or can optionally be + first converted to mzML or MGF. We recommend using the format that was passed to the search + engine. + +2. Run ``tims2rescore``: - Open a terminal or command prompt. - Navigate to the directory where your input files are located. - Execute the following command: .. code-block:: bash - timsrescore -p -s -o + tims2rescore -p -s + + Replace ``, ``, and `` with the + actual paths to your input and output files. - Replace ``, ``, and `` with the actual paths to your input and output files. - _NOTE_ By default timsTOF specific models will be used for predictions. Optionally you can further configure settings through a configuration file. For more information on configuring `timsrescore`, refer to the :doc:`configuration` tab in the user guide. + .. admonition:: note + + By default, specialized timsTOF models will be used for predictions. Optionally you can + further configure TIMS²Rescore through a configuration file. For more information, refer + to the :ref:`configuration` tab in the user guide. 3. Review the results: - - Once the `timsrescore` process completes, you will find the rescoring results in the specified output file or if not specified in the same directory as the input files - - If you want a detailed overview of the performance, you can either give the set `write_report` to `True` in the configuration file, use the `--write_report` option in the command line or run the following command: - + - Once the ``tims2rescore`` process completes, you will find the rescoring results in the + same directory as the input files. + - If you want a detailed report of the rescoring performance, you can either give the set + `write_report` to `True` in the configuration file, use the `--write_report` option in the + ``tims2rescore`` command line. Alternatively, run the following command after rescoring: + .. code-block:: bash ms2rescore-report - Replace `` with the actual output prefix of the result files to the output file. + Replace `` with the actual output prefix of the result files to the output + file. For instance, if the output file is ``identifications.psms.tsv``, then the output + prefix is ``identifications``. -Additional Options +Additional options ------------------ -`ms2rescore` provides additional options to customize the `timsrescore` process. You can explore these options by running the following command: +`tims2rescore` provides additional options to customize rescoring. You can explore these options +by running the following command: .. code-block:: bash - timsrescore --help + tims2rescore --help diff --git a/ms2rescore/__main__.py b/ms2rescore/__main__.py index 70e384c2..400a1fad 100644 --- a/ms2rescore/__main__.py +++ b/ms2rescore/__main__.py @@ -41,18 +41,24 @@ def _print_credits(tims=False): text = Text() text.append("\n") if tims: - text.append("TIMS²Rescore", style="bold link https://github.com/compomics/ms2rescore") + text.append("TIMS²Rescore", style="bold link https://github.com/compomics/tims2rescore") else: text.append("MS²Rescore", style="bold link https://github.com/compomics/ms2rescore") text.append(f" (v{__version__})\n", style="bold") if tims: - text.append("MS²Rescore tuned for Bruker timsTOF instruments.\n", style="italic") + text.append("MS²Rescore tuned for timsTOF DDA-PASEF data.\n", style="italic") text.append("Developed at CompOmics, VIB / Ghent University, Belgium.\n") text.append("Please cite: ") - text.append( - "Buur & Declercq et al. JPR (2024)", - style="link https://doi.org/10.1021/acs.jproteome.3c00785", - ) + if tims: + text.append( + "Declercq & Devreese et al. bioRxiv (2024)", + style="link https://doi.org/10.1101/2024.05.29.596400", + ) + else: + text.append( + "Buur & Declercq et al. JPR (2024)", + style="link https://doi.org/10.1021/acs.jproteome.3c00785", + ) text.append("\n") if tims: text.stylize("#006cb5") From 3a631b430b10111a30a13869ccd4af9b60b64577 Mon Sep 17 00:00:00 2001 From: RalfG Date: Thu, 18 Jul 2024 14:53:38 +0200 Subject: [PATCH 4/6] CI: Fix windows installer test (pip only binary) --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8830c6e0..26f9eb5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,7 @@ jobs: - name: Install package and dependencies run: | python -m pip install --upgrade pip - pip install . pyinstaller + pip install --only-binary :all: . pyinstaller - name: Install Inno Setup uses: crazy-max/ghaction-chocolatey@v1 From f8f38f800c768020f568c3e50dd3b6e2245cd32f Mon Sep 17 00:00:00 2001 From: RalfG Date: Thu, 18 Jul 2024 15:27:58 +0200 Subject: [PATCH 5/6] docs: Fix URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6d6b71a..f2ed978e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ timsTOF fragmentation and IM2Deep for ion mobility separation. Bruker .d and min files are directly supported through the [timsrust](https://github.com/MannLabs/timsrust) library. Checkout our [preprint](https://doi.org/10.1101/2024.05.29.596400) for more information and the -[TIMS²Rescore documentation](https://ms2rescore.readthedocs.io/userguide/tims2rescore) +[TIMS²Rescore documentation](https://ms2rescore.readthedocs.io/en/stable/userguide/tims2rescore) to get started. ## Citing From 696165a7f8a1d7e24ca3335e17c7723e20389fd4 Mon Sep 17 00:00:00 2001 From: ArthurDeclercq Date: Wed, 17 Jul 2024 13:29:34 +0200 Subject: [PATCH 6/6] updated versions --- ms2rescore/__init__.py | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ms2rescore/__init__.py b/ms2rescore/__init__.py index 606a1c8a..c99ef9b7 100644 --- a/ms2rescore/__init__.py +++ b/ms2rescore/__init__.py @@ -1,6 +1,6 @@ """MS²Rescore: Sensitive PSM rescoring with predicted MS² peak intensities and RTs.""" -__version__ = "3.1.0-dev9" +__version__ = "3.1.0" from warnings import filterwarnings diff --git a/pyproject.toml b/pyproject.toml index d25968bc..f829cceb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,8 +41,8 @@ dependencies = [ "jinja2>=3", "lxml>=4.5", "mokapot>=0.9", - "ms2pip>=4.0.0-dev10", - "ms2rescore_rs", + "ms2pip>=4.0.0", + "ms2rescore_rs>=0.3.0", "numpy>=1.16.0", "pandas>=1.0", "plotly>=5",