View source: R/remove_spectra.R
remove_spectra | R Documentation |
The remove_spectra()
function is used to discard specific spectra from (1) raw spectra list by removing them, or (2) processed spectra by removing them from the spectra, peaks and metadata objects.
remove_spectra(spectra_list, to_remove)
spectra_list |
A list of MALDIquant::MassSpectrum objects OR A list of processed spectra from process_spectra |
to_remove |
The spectra to be removed. In the case of raw spectra: a logical vector same size of |
The same object as spectra_list
minus the spectra in to_remove
.
# Get an example directory of six Bruker MALDI Biotyper spectra
directory_biotyper_spectra <- system.file(
"toy-species-spectra",
package = "maldipickr"
)
# Import only the first two spectra
spectra_list <- import_biotyper_spectra(directory_biotyper_spectra)[1:2]
# Introduce artificially an empty raw spectra
spectra_list <- c(spectra_list, MALDIquant::createMassSpectrum(0, 0))
# Empty spectra are detected by `check_spectra()`
# and can be removed by `remove_spectra()`
spectra_list %>%
remove_spectra(to_remove = check_spectra(.))
# Get an example processed spectra
processed_path <- system.file(
"three_processed_spectra_with_one_peakless.RDS",
package = "maldipickr")
processed <- readRDS(processed_path) %>% list()
# Remove a specific spectra
remove_spectra(processed, "empty_H12")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.