Skip to contents

Aggregate multiple processed spectra, their associated peaks and metadata into a feature matrix and a concatenated metadata table.


  remove_peakless_spectra = TRUE,
  interpolate_missing = TRUE



A list of the processed spectra and associated peaks and metadata in two possible formats:

  • A list of in-memory objects (named spectra, peaks, metadata) produced by process_spectra.

  • [Deprecated] A list of paths to RDS files produced by process_spectra when using the rds_prefix option.


A logical indicating whether to discard the spectra without detected peaks.


A logical indicating if intensity values for missing peaks should be interpolated from the processed spectra signal or left NA which would then be converted to 0.


A n×p matrix, with n spectra as rows and p features as columns that are the peaks found in all the processed spectra.

See also


# Get an example directory of six Bruker MALDI Biotyper spectra
directory_biotyper_spectra <- system.file(
  package = "maldipickr"
# Import the six spectra
spectra_list <- import_biotyper_spectra(directory_biotyper_spectra)
# Transform the spectra signals according to Strejcek et al. (2018)
processed <- process_spectra(spectra_list)
# Merge the spectra to produce the feature matrix
fm <- merge_processed_spectra(list(processed))
# The feature matrix has 6 spectra as rows and
#  35 peaks as columns
#> [1]  6 35
# Notice the difference when the interpolation is turned off
fm_no_interpolation <- merge_processed_spectra(
  interpolate_missing = FALSE
sum(fm == 0) # 0
#> [1] 0
sum(fm_no_interpolation == 0) # 68
#> [1] 68

# Multiple runs can be aggregated using list()
# Merge the spectra to produce the feature matrix
fm_all <- merge_processed_spectra(list(processed, processed, processed))
# The feature matrix has 3×6=18 spectra as rows and
#  35 peaks as columns
#> [1] 18 35