remove_noise: Remove Noise from MS2 Spectrum

View source: R/53_ms2_spectra_matching_scores.R

remove_noiseR Documentation

Remove Noise from MS2 Spectrum

Description

This function removes noisy fragments from an MS2 spectrum based on mass-to-charge ratio (m/z) tolerance and intensity comparison, ensuring that only the most relevant peaks are retained.

Usage

remove_noise(spectrum, ms2.match.ppm = 30, mz.ppm.thr = 400)

Arguments

spectrum

A data frame representing the MS2 spectrum, with columns 'mz' for mass-to-charge ratios and 'intensity' for corresponding intensities.

ms2.match.ppm

Numeric. The mass tolerance in parts per million (ppm) for determining whether peaks are considered duplicates/noise. Default is 30.

mz.ppm.thr

Numeric. A threshold for m/z values to use in ppm calculation. If the m/z difference is below this value, it is set to this threshold. Default is 400.

Details

The function sorts the spectrum by m/z values and calculates the differences between adjacent fragments. If the difference between any two fragments' m/z values is less than the specified ppm threshold, the fragment with the lower intensity is removed. This helps clean the spectrum by filtering out low-intensity fragments that are close to higher-intensity ones.

Value

A data frame with the noisy fragments removed. The data frame retains the columns 'mz' and 'intensity' for the cleaned spectrum.

Author(s)

Xiaotao Shen xiaotao.shen@outlook.com

Examples

## Not run: 
# Example spectrum
spectrum <- data.frame(mz = c(100, 100.001, 150, 200, 250), intensity = c(10, 5, 50, 100, 30))

# Remove noise from the spectrum
clean_spectrum <- remove_noise(spectrum = spec, ms2.match.ppm = 30, mz.ppm.thr = 400)

print(clean_spec)

## End(Not run)


tidymass/metid documentation built on Oct. 8, 2024, 10:32 p.m.