Feature Map Annotation with Peptide Identifications#

A feature map is usually obtained from running a feature finder, e.g. FeatureFinderAlgorithmPicked (see Feature Detection). A logical next step is to compare features across runs using Map Alignment and Feature Linking. However, most map aligners in pyOpenMS require features which are annotated with PSMs (see Identication Data). To link features to their respective PSMs (as obtained from a search engine, such as Comet), we can use the IDMapper.

Step 0: Download Example data#

 1import pyopenms as oms
 2from urllib.request import urlretrieve
 3
 4base_url = (
 5    "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master/src/data/"
 6)
 7
 8feature_file = "BSA1_F1.featureXML"
 9urlretrieve(base_url + feature_file, feature_file)
10
11idxml_file = "BSA1_F1.idXML"
12urlretrieve(base_url + idxml_file, idxml_file)

Step 1: Load the Feature Map#

First, load the FeatureMap from a .featureXML file:

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:

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:

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:

id_mapper.annotate(feature_map, peptide_ids, protein_ids, use_centroid_rt=True, use_centroid_mz=True, spectra=None)

Step 5: Save the Annotated FeatureMap#

Finally, store the modified FeatureMap back to a file:

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.