Skip to contents

Extracts the UV-VIS spectrum at a specified retention time from one or more chromatograms in a chrom_list.

Usage

get_spectra(
  loc,
  peak_table,
  chrom_list = NULL,
  idx = seq_along(chrom_list),
  scale_spectrum = FALSE,
  what = c("peak", "rt", "idx"),
  format = c("wide", "long")
)

Arguments

loc

Peak or retention time to extract the spectrum at. Interpretation depends on what.

peak_table

A peak_table object. Required if what == "peak".

chrom_list

A list of chromatographic matrices. If NULL, the list is found through the pointer in peak_table.

idx

Indices of chromatograms to extract spectra from. Defaults to all chromatograms in chrom_list.

scale_spectrum

Logical. Whether to normalize absorbance values to the range [0, 1]. Defaults to FALSE.

what

How to interpret loc. One of "peak" (look up retention time from peak_table), "rt" (treat loc as a retention time directly), or "idx" (treat loc as a row index). Defaults to "peak".

format

One of "wide" or "long". In wide format, wavelengths are rows and each column is a sample. In long format, columns are wavelength, absorbance, sample, and rt. Defaults to "wide".

Value

Returns a data.frame in the format specified by format.

Examples

data(pk_tab)
data(Sa_warp)
get_spectra("V8", peak_table = pk_tab)
#>           119       121       122       458
#> 200 21.973475 23.315240 12.335922 47.520350
#> 202 23.083855 23.074514 12.743100 48.471768
#> 204 23.218223 21.804216 12.405388 47.697296
#> 206 22.204197 19.578938 11.784498 44.872779
#> 208 20.462533 16.887954 10.715371 41.060680
#> 210 18.570196 14.308790  9.688007 37.004217
#> 212 16.632000 12.226251  8.845258 33.443075
#> 214 14.193818 10.875514  8.029784 30.662396
#> 216 11.764069 10.066278  7.451309 28.464990
#> 218  9.941000  9.512968  7.015400 26.991975
#> 220  8.850931  9.240496  6.797146 25.831905
#> 222  8.168859  8.941525  6.286988 24.594329
#> 224  7.595573  8.662743  5.844055 23.369866
#> 226  7.107136  8.275337  5.347975 21.702742
#> 228  6.829752  7.860495  4.993954 19.875695
#> 230  6.745479  7.424255  4.818955 18.078550
#> 232  6.773550  6.964516  4.737642 16.441224
#> 234  6.716852  6.531802  4.536046 14.870604
#> 236  6.546370  6.079715  4.247510 13.411029
#> 238  6.307598  5.622773  4.093362 12.315706
#> 240  5.999858  5.122268  3.937995 11.358281
#> 242  5.660276  4.735870  3.829152 10.649038
#> 244  5.294826  4.381020  3.800156 10.050053
#> 246  4.939563  4.087155  3.804302  9.485904
#> 248  4.595177  3.863154  3.784116  8.981096
#> 250  4.228571  3.568998  3.668520  8.603649
#> 252  3.896796  3.320429  3.468668  8.076883
#> 254  3.556864  3.103578  3.348597  7.765515
#> 256  3.202875  2.907588  3.168427  7.425202
#> 258  2.855508  2.735278  3.011403  7.211324
#> 260  2.591447  2.598221  2.875123  7.180781
#> 262  2.471957  2.555108  2.782513  7.287757
#> 264  2.448640  2.666018  2.864592  7.629555
#> 266  2.539808  2.808560  2.890038  8.132379
#> 268  2.716140  2.991076  3.062912  8.673437
#> 270  2.958778  3.296662  3.154885  9.311232
#> 272  3.318910  3.658324  3.435380 10.064918
#> 274  3.698475  4.017313  3.735793 10.751136
#> 276  4.026220  4.359352  3.851217 11.311330
#> 278  4.380727  4.741702  4.048522 12.048076
#> 280  4.750621  5.146839  4.467763 12.547534
#> 282  5.066798  5.490299  4.811692 13.120436
#> 284  5.377400  5.831255  5.207352 13.514591
#> 286  5.617242  6.146542  5.581628 13.783939
#> 288  5.850786  6.318477  5.913353 13.971421
#> 290  6.084707  6.522189  6.337822 14.109863
#> 292  6.302111  6.912283  6.877115 14.253350
#> 294  6.466815  7.309907  7.216876 14.522774
#> 296  6.609444  7.630262  7.697018 14.773130
#> 298  6.721011  7.954098  8.002300 14.881625
#> 300  6.822011  8.355626  8.316483 15.001421
#> 302  6.845491  8.621325  8.535023 15.031804
#> 304  6.865925  8.866213  8.722520 14.962401
#> 306  6.954650  9.224344  8.982139 14.927669
#> 308  7.052165  9.555207  9.245769 15.150338
#> 310  7.164577  9.925712  9.502669 15.234270
#> 312  7.294807 10.264468  9.765227 15.473733
#> 314  7.437203 10.535517  9.946261 15.724815
#> 316  7.589238 10.729417 10.090334 16.042358
#> 318  7.747059 10.833917 10.092255 16.120594