-
Notifications
You must be signed in to change notification settings - Fork 70
fix PSM_to_features tutorial #476
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
Conversation
WalkthroughA code snippet in the user guide was updated to explicitly create an empty Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant MSExperiment
participant IDMapper
User->>MSExperiment: Create empty instance (spectra)
User->>IDMapper: annotate(feature_map, peptide_ids, protein_ids, True, True, spectra)
IDMapper->>MSExperiment: Uses spectra for annotation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Assessment against linked issues
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/source/user_guide/PSM_to_features.rst (2)
72-73: Add a brief explanation for creating an emptyMSExperimentThe snippet now instantiates
spectra = oms.MSExperiment()solely to satisfy the type requirement ofIDMapper.annotate. A short inline comment (e.g.,# empty experiment required by annotate) or a one-sentence note above the cell would help readers understand why this seemingly unused object is necessary.
73-73: Positional flags reduce readability; leave a reminder to revert to keywordsSwitching to positional arguments (
True, True, spectra) works around the current binding issue but obscures the meaning of each flag and ties the example to the exact parameter order. Consider adding a TODO comment indicating that, once the pyOpenMS binding accepts keyword arguments again, the call should be restored to a clearer form:# TODO: switch back once fixed upstream # id_mapper.annotate(feature_map, peptide_ids, protein_ids, # use_centroid_rt=True, use_centroid_mz=True, spectra=spectra)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/source/user_guide/PSM_to_features.rst(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-test
- GitHub Check: build-test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blacken-docs] reported by reviewdog 🐶
pyopenms-docs/docs/source/user_guide/PSM_to_features.rst
Lines 1 to 91 in 33c7a02
| Feature Map Annotation with Peptide Identifications | |
| =================================================== | |
| A :term:`feature map` is usually obtained from running a :term:`feature finder`, e.g. :py:class:`~.FeatureFinderAlgorithmPicked` (see `Feature Detection <feature_detection.html>`_). | |
| A logical next step is to compare features across runs using `Map Alignment <map_alignment.html>`_ and `Feature Linking <feature_linking.html>`_. | |
| However, most map aligners in pyOpenMS require features which are annotated with PSMs (see `Identication Data <identification_data.html>`_). | |
| To link features to their respective PSMs (as obtained from a search engine, such as Comet), we can use the :py:class:`~.IDMapper`. | |
| Step 0: Download Example data | |
| ----------------------------- | |
| .. code-block:: python | |
| :linenos: | |
| import pyopenms as oms | |
| from urllib.request import urlretrieve | |
| base_url = ( | |
| "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master/src/data/" | |
| ) | |
| feature_file = "BSA1_F1.featureXML" | |
| urlretrieve(base_url + feature_file, feature_file) | |
| idxml_file = "BSA1_F1.idXML" | |
| urlretrieve(base_url + idxml_file, idxml_file) | |
| Step 1: Load the Feature Map | |
| ---------------------------- | |
| First, load the FeatureMap from a `.featureXML` file: | |
| .. code-block:: python | |
| import pyopenms as oms | |
| feature_map = oms.FeatureMap() | |
| oms.FeatureXMLFile().load(feature_file, feature_map) | |
| Step 2: Load Peptide Identifications | |
| ------------------------------------ | |
| Next, load the PeptideIdentifications from an `.idXML` file: | |
| .. code-block:: python | |
| peptide_ids = [] | |
| protein_ids = [] | |
| oms.IdXMLFile().load(idxml_file, protein_ids, peptide_ids) | |
| Step 3: Initialize and Configure `IDMapper` | |
| ------------------------------------------- | |
| Now, configure `IDMapper` to apply **retention time (RT) and m/z tolerance settings**: | |
| .. code-block:: python | |
| id_mapper = oms.IDMapper() | |
| params = id_mapper.getParameters() | |
| params.setValue("rt_tolerance", 5.0) # RT tolerance in seconds | |
| params.setValue("mz_tolerance", 10.0) # m/z tolerance in ppm | |
| id_mapper.setParameters(params) | |
| Step 4: Annotate the FeatureMap | |
| ------------------------------- | |
| Use the configured `IDMapper` to link peptide IDs to the FeatureMap: | |
| .. code-block:: python | |
| # annotate() can optionally use the underlying raw MS data (spectra) to annotate unidentified MS/MS scans to features in the FeatureMap | |
| # We don't need this here, so we provide an empty default. | |
| spectra = oms.MSExperiment() | |
| id_mapper.annotate(feature_map, peptide_ids, protein_ids, True, True, spectra) | |
| Step 5: Save the Annotated FeatureMap | |
| -------------------------------------- | |
| Finally, store the modified FeatureMap back to a file: | |
| .. code-block:: python | |
| oms.FeatureXMLFile().store("BSA1_F1_annotated.featureXML", feature_map) | |
| .. tip:: | |
| You can visualize the annotated FeatureMap using OpenMS visualization tools like `TOPPView`. | |
| You have successfully **annotated a FeatureMap** with PeptideIdentifications using `IDMapper`. This allows further downstream analysis in (py)OpenMS workflows. | |
fixes OpenMS/OpenMS#8139
Summary by CodeRabbit