
Compare phase-specific and unrestricted spectral library evidence
Source:R/librarySearchEvidence.R
librarySearchEvidence.RdThe two searches rank candidates independently. A better spectral match without a measured index for the selected phase remains available for review.
Usage
librarySearchEvidence(
x,
library,
calibration = NULL,
ri = NULL,
phase = c("DB5", "DB1", "DBWAX"),
ri_tolerance = 30,
...
)Arguments
- x
A gcmsDeco fit, or a compound-by-mass matrix with numeric mass names.
- library
A GCMSlibrary returned by readMSP(), readGCMSID() or openLibrary().
- calibration
RIcalibration from calibrateRI(). For gcmsDeco fits, the stored alkane standard and calibrated PSF widths are used automatically when available.
- ri
Optional RI vector, one value per query; overrides profile-based timing.
- phase
RI column class: DB1 (nonpolar), DB5 (semi-standard nonpolar), or DBWAX (polar).
- ri_tolerance
Maximum absolute RI difference, default 30. Inf requests an unconstrained spectral comparison, also allowing references without RI.
- ...
Other options for [librarySearch()], including method, n_matches, distinct, min_shared, ncores and unknown_phase.
Value
A list with phase and spectral (GCMSmatches objects). Each returned match has ri_status: compatible, outside_tolerance, missing_reference_ri, or missing_query_ri. The latter takes precedence for an uncalibrated query. An unknown phase explicitly mapped by the caller is recorded in ri_assumed. No RI is imputed across columns or from an unrelated library record.
Examples
f <- tempfile(fileext = ".msp")
writeLines(c("Name: A", "RI_DB5: 1000", "Num Peaks: 2", "43 100; 57 50;",
"Name: B", "Num Peaks: 2", "43 100; 57 75;"), f)
x <- matrix(c(100, 75), 1, dimnames = list(NULL, c("43", "57")))
librarySearchEvidence(x, readMSP(f), ri = 1001, method = "cosine")$spectral$matches
#> query library_id shared_ions method distance library_RI library_total
#> 1 1 2 2 cosine 0.000 NA 175
#> 2 1 1 2 cosine 0.032 1000 150
#> reference_total reference_count library_mass_coverage query_RI delta_RI rank
#> 1 175 query 1 1001 NA 1
#> 2 175 query 1 1001 -1 2
#> name cas inchikey source source_id origin ri_phase ri_assumed
#> 1 B <NA> <NA> file19c810702058.msp <NA> unknown <NA> FALSE
#> 2 A <NA> <NA> file19c810702058.msp <NA> unknown DB5 FALSE
#> ri_origin ri_source query_total compound score
#> 1 <NA> <NA> 175 1 1000
#> 2 unknown file19c810702058.msp 175 1 968
#> ri_status
#> 1 missing_reference_ri
#> 2 compatible