matchms.networking.networking_functions module

Helper functions to build and handle spectral networks.

matchms.networking.networking_functions.get_top_hits(scores: <module 'matchms.Scores' from '/home/docs/checkouts/readthedocs.org/user_builds/matchms/checkouts/development/matchms/Scores.py'>, top_n: int = 25, axis: int = 1, score_name: str | None = None, identifiers: Sequence | None = None, ignore_diagonal: bool = False) tuple[dict, dict][source]

Get top_n highest scores and corresponding indices for each row or column.

Parameters:
  • scores – Matchms Scores object containing similarity values.

  • top_n – Number of top hits to return per row or column.

  • axis – Axis along which to search: - axis=1: get top hits for each row - axis=0: get top hits for each column

  • score_name – Name of the score field to use when scores contains multiple fields. If None: - scalar Scores: the only field is used - multi-field Scores: defaults to "score" if available, otherwise raises

  • identifiers – Optional identifiers for the selected axis. - for axis=1, must have length scores.shape[0] - for axis=0, must have length scores.shape[1] If None, integer indices are used as dictionary keys.

  • ignore_diagonal – If True, diagonal self-hits are excluded. This is only meaningful for square score matrices where row and column indices refer to the same set.

Returns:

Two dictionaries: - keys are identifiers (or integer row/column indices) - values are NumPy arrays of hit indices and hit scores

Return type:

similars_idx, similars_scores

matchms.networking.networking_functions.get_top_hits_by_column(scores: <module 'matchms.Scores' from '/home/docs/checkouts/readthedocs.org/user_builds/matchms/checkouts/development/matchms/Scores.py'>, top_n: int = 25, score_name: str | None = None, identifiers: Sequence | None = None, ignore_diagonal: bool = False) tuple[dict, dict][source]

Get top hits for each column.

matchms.networking.networking_functions.get_top_hits_by_row(scores: <module 'matchms.Scores' from '/home/docs/checkouts/readthedocs.org/user_builds/matchms/checkouts/development/matchms/Scores.py'>, top_n: int = 25, score_name: str | None = None, identifiers: Sequence | None = None, ignore_diagonal: bool = False) tuple[dict, dict][source]

Get top hits for each row.