Skip to main content

Create spectral similarity network edges

Description

Calculates pairwise spectral similarity between all spectra to create a network edge list.

Usage

create_edges(
  frags,
  nspecs,
  precs,
  method,
  ms2_tolerance,
  ppm_tolerance,
  threshold = 0.1,
  matched_peaks = 1L,
  assume_sanitized = FALSE
)

Arguments

frags List of aligned fragment spectra matrices
nspecs Integer number of spectra
precs Numeric vector of precursor m/z values
method Similarity method ("entropy", "gnps", or "cosine")
ms2_tolerance MS2 tolerance in Daltons
ppm_tolerance PPM tolerance
threshold Minimum similarity score threshold (default: 0.1). Pairs with similarity scores below this threshold are discarded to filter out random background noise and prevent memory overflow. Set to NULL to disable similarity thresholding and retain all pairwise comparisons.
matched_peaks Minimum number of matched peaks required. Set to NULL to disable matched-peak filtering.
assume_sanitized Boolean flag to assume if sanitize or not. FALSE

Value

Data frame with columns: feature_id, target_id, score, matched_peaks. Returns empty data frame with NA values if no edges pass thresholds.

See Also

Other workflow: change_params_small(), create_components(), create_edges_spectra(), go_to_cache(), install(), install_tima(), run_app(), run_tima(), tima_full(), validate_inputs()

Examples

library("tima")

edges <- create_edges(
  frags = fragment_list,
  nspecs = length(fragment_list),
  precs = precursor_mz,
  method = "gnps",
  ms2_tolerance = 0.02,
  ppm_tolerance = 10,
  threshold = 0.7,
  matched_peaks = 6L
)