Get IMS spectrum from a sample

getSpectrum(
  object,
  dt_range = NULL,
  rt_range = NULL,
  dt_idx = NULL,
  rt_idx = NULL,
  aggregate = rowSums
)

Arguments

object

A GCIMSSample object

dt_range

The minimum and maximum drift times to extract (length 2 vector)

rt_range

The minimum and maximum retention times to extract (length 2 vector)

dt_idx

A numeric vector with the drift time indices to extract (or a logical vector of the length of drift time)

rt_idx

A numeric vector with the retention time indices to extract (or a logical vector of the length of retention time)

aggregate

Function that takes the subsetted intensity matrix according to the region of interest and aggregates the retention times, returning a vector representing the spectrum intensity. rowSums by default.

Value

A GCIMSSpectrum object

Examples

x <- GCIMSSample(
  drift_time = 1:2,
  retention_time = 1:3,
  data = matrix(1:6, nrow = 2, ncol = 3)
)
getSpectrum(x, rt_idx = 2)
#> An object of class "GCIMSSpectrum"
#> Slot "drift_time":
#> [1] 1 2
#> 
#> Slot "intensity":
#> 1 2 
#> 3 4 
#> 
#> Slot "baseline":
#> NULL
#> 
#> Slot "retention_time_idx":
#> [1] 2
#> 
#> Slot "retention_time_s":
#> [1] 2
#> 
#> Slot "description":
#> character(0)
#> 
#> Slot "peaks":
#> NULL
#> 
#> Slot "peaks_debug_info":
#> NULL
#> 

# Take the maximum intensity in the region for each drift time:
sp1 <- getSpectrum(x, aggregate = function(x) apply(x, 1, max))