if (FALSE) {
if (requireNamespace("MALDIquant", quietly = TRUE)) {
set.seed(1)
# Create a small training set (mod_peaks) with 2 classes
p <- 6
moz <- as.character(round(seq(1000, 1500, length.out = p), 2))
mod_peaks <- rbind(
matrix(runif(5 * p, 0, 1), nrow = 5, dimnames = list(NULL, moz)),
matrix(runif(5 * p, 0, 1), nrow = 5, dimnames = list(NULL, moz))
)
Y_mod <- factor(rep(c("A", "B"), each = 5))
# Two spectra to classify: generate MassPeaks near moz
mk_peaks <- function(shift = 0) {
MALDIquant::createMassPeaks(
mass = as.numeric(moz) + rnorm(length(moz), shift, 0.2),
intensity = runif(length(moz), 10, 100)
)
}
peaks <- list(mk_peaks(0.1), mk_peaks(-0.1))
res <- PredictFastClass(
peaks = peaks,
mod_peaks = mod_peaks,
Y_mod_peaks = Y_mod,
moz = "ALL",
tolerance = 1,
normalizeFun = TRUE
)
res
}
}
Run the code above in your browser using DataLab