merge_processed_spectra {maldipickr}R Documentation

Merge multiple processed spectra and peaks

Description

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

Usage

merge_processed_spectra(
  processed_spectra,
  remove_peakless_spectra = TRUE,
  interpolate_missing = TRUE
)

Arguments

processed_spectra

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.

remove_peakless_spectra

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

interpolate_missing

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.

Value

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

process_spectra, the "Value" section in MALDIquant::intensityMatrix

Examples

# Get an example directory of six Bruker MALDI Biotyper spectra
directory_biotyper_spectra <- system.file(
  "toy-species-spectra",
  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
dim(fm)
# Notice the difference when the interpolation is turned off
fm_no_interpolation <- merge_processed_spectra(
  list(processed),
  interpolate_missing = FALSE
)
sum(fm == 0) # 0
sum(fm_no_interpolation == 0) # 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
dim(fm_all)

[Package maldipickr version 1.3.0 Index]