Navigate an MSnExp object by moving to the next or previous spectrum.

navMS(i, object, msLevel, nav = c("nextMS", "prevMS"), ...)

nextMS(...)

prevMS(...)

Arguments

i

The name or index of the current spectrum

object

The MSnExp object

msLevel

The MS level of the next or previous spectrum. If missing (default), then the level of the current spectrum is used.

nav

One of "nextMS" or "prevMS", to obtain the next or previous spectrum of level msLevel.

...

Additional parameters. Currently ignored.

Value

An object of class Spectrum1 or Spectrum2, depending on the value of msLevel or NULL, of no spectrum is found.

Author

Laurent Gatto

Examples

f <- msdata::proteomics(full.names = TRUE, pattern = "MS3")
x <- readMSData(f, centroided. = c(FALSE, TRUE, FALSE), mode = "onDisk")
#> Warning: Reading different file formats in.
#> This is untested and you are welcome to try it out.
#> Please report back!
(sp <- which(msLevel(x) == 3)[2]) ## 2nd MS3 spectrum
#> F1.S009 
#>       9 
x[[sp]] ## curent MS3
#> Object of class "Spectrum2"
#>  Precursor: 756.4332 
#>  Retention time: 73:43 
#>  Charge: 1 
#>  MSn level: 3 
#>  Peaks count: 1422 
#>  Total ion count: 972514 
MSnbase:::nextMS(sp, x) ## next MS3
#> Object of class "Spectrum2"
#>  Precursor: 466.1647 
#>  Retention time: 73:44 
#>  Charge: 0 
#>  MSn level: 3 
#>  Peaks count: 2281 
#>  Total ion count: 3908748 
MSnbase:::prevMS(sp, x) ## prev MS3
#> Object of class "Spectrum2"
#>  Precursor: 490.2629 
#>  Retention time: 73:43 
#>  Charge: 0 
#>  MSn level: 3 
#>  Peaks count: 2540 
#>  Total ion count: 9311294 
MSnbase:::prevMS(sp, x, 2L) ## prev MS2
#> Object of class "Spectrum2"
#>  Precursor: 675.6938 
#>  Retention time: 73:43 
#>  Charge: 3 
#>  MSn level: 2 
#>  Peaks count: 858 
#>  Total ion count: 627600.3 
MSnbase:::prevMS(sp, x, 1L) ## prev MS1
#> Object of class "Spectrum1"
#>  Retention time: 73:43 
#>  MSn level: 1 
#>  Total ion count: 48304 
#>  Polarity: 1