###############################################################################
## 1. Pre-processing of mass spectra
# load mass spectra and their metadata
data("CitrobacterRKIspectra","CitrobacterRKImetadata", package = "MSclassifR")
# standard pre-processing of mass spectra
spectra <- MSclassifR::SignalProcessing(CitrobacterRKIspectra)
# detection of peaks in pre-processed mass spectra
peaks <- MSclassifR::PeakDetection(x = spectra, labels = CitrobacterRKImetadata$Strain_name_spot)
# build matrix with intensities of peaks (rows = samples, columns = m/z)
Y <- factor(CitrobacterRKImetadata$Species)
xy <- build_XY_from_peaks(peaks, labels = Y, normalize = "max", sparse = FALSE)
X <- xy$X
Y <- xy$Y
###############################################################################
## 2. Estimate the optimal number of peaks to discriminate the different species
OptiPeaks <- MSclassifR::SelectionVarStat(X,
Y,
stat.test = "Limma",
pi0.method = "abh",
fdr = 0.05,
Sampling = "smote",
seed = 1)
## Estimation of the optimal number of peaks to discriminate species (from the pi0 parameter)
OptiPeaks$nb_to_sel
## discriminant mass-to-charge values estimated using a 5 per cent false discovery rate
OptiPeaks$sel_moz
## p-values and adjusted p-values estimated for all the tested mass-to-charge values
OptiPeaks$ap$adjp
Run the code above in your browser using DataLab