# Minimal example with synthetic MassPeaks
if (requireNamespace("MALDIquant", quietly = TRUE)) {
set.seed(1)
# Two spectra with slightly jittered peaks around 1000, 1500, 2000 Da
mz1 <- c(999.7, 1500.2, 2000.1); int1 <- c(10, 50, 30)
mz2 <- c(1000.3, 1499.8, 2000.4); int2 <- c(12, 60, 28)
p1 <- MALDIquant::createMassPeaks(mass = mz1, intensity = int1)
p2 <- MALDIquant::createMassPeaks(mass = mz2, intensity = int2)
peaks <- list(p1, p2)
# Target m/z grid (unsorted, will be sorted internally)
moz <- c(2000, 1500, 1000)
X <- build_X_from_peaks_fast(peaks, moz, tolerance = 1, normalize = TRUE)
dim(X)
colnames(X)
X
}
# Typical usage in a pipeline:
# spectra <- SignalProcessing(yourSpectra)
# peaks <- MSclassifR::PeakDetection(x = spectra, averageMassSpec = FALSE)
# moz <- c(1000, 1500, 2000) # from selection or prior knowledge
# X <- build_X_from_peaks_fast(peaks, moz, tolerance = 6, normalize = TRUE)
# Then pass X to SelectionVar/SelectionVarStat_fast/LogReg, etc.
Run the code above in your browser using DataLab