OpenMS
Loading...
Searching...
No Matches
IonIdentityMolecularNetworking Class Reference

Helpers for the Ion Identity Molecular Networking (IIMN) workflow on GNPS. More...

#include <OpenMS/ANALYSIS/ID/IonIdentityMolecularNetworking.h>

Static Public Member Functions

static void annotateConsensusMap (ConsensusMap &consensus_map)
 Populate the IIMN meta values on consensus_map in-place.
 
static void writeSupplementaryPairTable (const ConsensusMap &consensus_map, const std::string &output_file)
 Write the IIMN supplementary pairs CSV consumed by GNPS.
 

Detailed Description

Helpers for the Ion Identity Molecular Networking (IIMN) workflow on GNPS.

IIMN extends GNPS Feature-Based Molecular Networking by grouping consensus features that represent the same compound seen as different adducts (e.g. [M+H]+ and [M+Na]+). The grouping information is usually produced upstream by an adduct decharger (e.g. MetaboliteAdductDecharger), which records a set of adduct-group IDs in the Constants::UserParam::IIMN_LINKED_GROUPS meta value on each consensus feature.

Two stages live in this class:

  1. annotateConsensusMap() consumes IIMN_LINKED_GROUPS, builds a bipartite graph (consensus feature ↔ adduct group), runs Boost connected-components on it, and writes back three IIMN meta values: a 1-based row id, the network number, and the list of partner-feature row ids. The IIMN_LINKED_GROUPS meta value is consumed and removed.
  2. writeSupplementaryPairTable() turns those annotations into the CSV file required by GNPS IIMN as the "supplementary pairs" upload.

Output of stage 1 is also a precondition for the meta-value / quantification tables written by GNPSMetaValueFile and GNPSQuantificationFile, and is invoked by the GNPSExport tool.

Member Function Documentation

◆ annotateConsensusMap()

static void annotateConsensusMap ( ConsensusMap consensus_map)
static

Populate the IIMN meta values on consensus_map in-place.

Reads Constants::UserParam::IIMN_LINKED_GROUPS (a list of adduct-group ids, typically from MetaboliteAdductDecharger), constructs a bipartite graph whose nodes are either consensus features or adduct groups, computes its connected components, and writes three meta values per feature:

  • IIMN_ROW_ID — 1-based index of the feature in consensus_map (assigned to every feature, including those with no group annotation).
  • IIMN_ANNOTATION_NETWORK_NUMBER — 1-based connected-component id; features that are direct or transitive adduct partners share this id. Set only on features that carried IIMN_LINKED_GROUPS.
  • IIMN_ADDUCT_PARTNERS — semicolon-separated list of partner IIMN_ROW_ID values; set only on features that share at least one adduct group.

The IIMN_LINKED_GROUPS meta value is consumed and removed from every feature when the routine returns.

Parameters
[in,out]consensus_mapMap to annotate. Features that lack IIMN_LINKED_GROUPS receive only IIMN_ROW_ID.

Referenced by TOPPGNPSExport::main_().

◆ writeSupplementaryPairTable()

static void writeSupplementaryPairTable ( const ConsensusMap consensus_map,
const std::string &  output_file 
)
static

Write the IIMN supplementary pairs CSV consumed by GNPS.

Emits one row per pair of features that share at least one adduct group, with columns:

  • ID1, ID2IIMN_ROW_ID of the two features (from annotateConsensusMap).
  • EdgeType — fixed string "MS1 annotation".
  • Score — number of direct partners across both sides of the pair (sum of each side's partner counts, minus 2 to remove the self-counts).
  • Annotation — best-ion adduct string for each side (defaulting to "default" if no IIMN_BEST_ION was set) plus the absolute delta m/z between the two precursors.

Reverse edges are deduplicated as the file is written (only one row per unordered pair). The schema matches https://ccms-ucsd.github.io/GNPSDocumentation/fbmn-iin/#supplementary-pairs.

Note
Returns silently if the first feature has no IIMN_ROW_ID (i.e. annotateConsensusMap has not been run on consensus_map).
Parameters
[in]consensus_mapAnnotated consensus map (call annotateConsensusMap first).
[in]output_fileDestination CSV path (overwritten if it exists).

Referenced by TOPPGNPSExport::main_().