R Under development (unstable) (2025-09-01 r88761 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(albatross) > library(tools) > > ho_aq <- system.file('extdata/ho_aq.csv', package = 'albatross') > aq <- feem(ho_aq, 'table', sep = ',') > > # 80% of values in the file are between -50 and 50, no NAs > stopifnot( + sum(aq > -50 & aq < 50) / length(aq) > .80 + ) > > pano1 <- as.data.frame(feem( + system.file('extdata/panorama.dat', package = 'albatross'), + 'panorama' + )) > with(pano1, stopifnot( + # anti-Stokes + 10nm not measured + emission >= excitation + 10, + # intensity between .2 and .6 + intensity > .2, intensity < .6, + min(intensity) < .25, max(intensity) > .55 + )) > > # must understand all these parameters > if ('CP1251' %in% iconvlist()) { + pano2 <- as.data.frame(feem( + system.file('extdata/panorama.txt', package = 'albatross'), + 'table', fileEncoding = 'CP1251', transpose = TRUE, na = 0 + )) + with(pano2, stopifnot( + # anti-Stokes not measured + emission >= excitation, + # 90% values between .25 and 3 + sum(intensity > .25 & intensity < 3) / length(intensity) > .9 + )) + } > > # pano2.txt should contain the same information as panorama.txt > pano3 <- as.data.frame(feem( + system.file('extdata/pano2.txt', package = 'albatross'), + 'table', transpose = TRUE, na = 0 + )) > if ('CP1251' %in% iconvlist()) + stopifnot(all.equal(pano2, pano3)) > > # make sure that feem.connection works for both formats > f1 <- file(ho_aq) > feem(f1, 'table', sep = ',') excitation emission 700 698 696 694 692 690 244.073 10.269960 7.977021 30.35472973 -2.328275 34.468560 2.03480947 246.313 43.800108 2.564824 -65.66168468 2.317767 -25.831208 0.01354354 248.554 -30.926432 -26.334430 0.01034481 18.696244 8.652512 -7.94962836 250.796 -2.658860 2.699612 28.40440809 9.574213 26.452097 10.27678682 253.039 -38.735248 76.524774 5.08701958 9.416883 45.328626 -22.19238221 255.282 -34.035590 -37.390018 10.26907376 14.244473 17.436402 18.37200018 257.527 7.903800 8.235867 -33.60373150 -31.111216 -8.705471 10.41117964 259.773 10.709116 -19.226266 28.92581434 46.299296 64.966897 -16.80241304 262.019 16.429462 -69.899920 24.23808289 19.927772 -6.846564 2.19073764 264.267 -30.682302 25.696139 -51.98756746 -70.898789 -25.618963 -19.62593205 266.516 -2.836168 -11.719804 66.86615232 30.933408 16.616738 57.84674901 268.765 25.919370 -64.706393 28.20244034 18.236833 -36.137467 -13.52439320 271.015 -43.685095 3.110388 -48.44338050 -15.778110 -24.186534 -36.38306795 273.267 34.760272 38.634207 -42.55971546 -65.684723 -12.081067 31.88495085 275.519 51.781891 -64.723488 -16.91380139 44.367632 -4.887528 29.25955424 277.772 -5.696399 -20.454881 11.00959177 -59.549210 -71.459828 -11.21724229 excitation emission 688 686 684 682 680 678 244.073 -13.440958 20.619589 7.42738667 5.562239 26.036202 22.16240134 246.313 9.636695 14.942463 -1.88895017 23.988398 -29.764462 14.77836966 248.554 5.865599 11.286338 29.50869396 11.155392 9.321645 -66.44082569 250.796 -21.812615 9.576673 11.31519463 -39.706084 -30.446042 26.44076767 253.039 3.971788 -39.377843 7.44627826 37.150403 11.198302 5.57611483 255.282 -29.475582 9.513327 -0.02006418 -24.429310 15.107313 -31.86577733 257.527 -11.782725 9.639434 -1.83433651 11.379139 -5.692682 15.15089606 259.773 12.182749 -7.771579 17.21514765 -7.672319 5.811505 61.53336964 262.019 4.154747 -27.815273 17.62555794 -17.659619 -9.866108 -76.51010520 264.267 27.186822 18.249207 45.87396424 40.045065 24.161333 -2.00111459 266.516 -23.472573 6.174977 22.32166766 14.192665 -6.184298 59.09731121 268.765 28.081416 -54.423854 22.59625745 -33.065546 -51.941423 -72.24534750 271.015 2.336267 57.130201 -51.92957155 58.559356 21.019400 0.06112802 273.267 -17.356187 18.963847 20.72253123 4.226305 -12.552503 29.09623797 275.519 64.752570 -37.637761 18.45860068 -22.769063 6.232775 2.08947726 277.772 -30.021436 45.547422 -42.81356726 47.023749 -20.626293 20.37601875 excitation emission 676 674 672 244.073 -14.375061 -1.74624715 1.737743 246.313 -5.455707 -26.67679830 3.544070 248.554 -19.914045 26.74724908 7.015523 250.796 35.244046 -16.34596176 23.210112 253.039 -72.610348 26.75297086 -24.440122 255.282 49.777439 -5.41245318 10.638270 257.527 26.080995 11.04536018 -28.564271 259.773 -3.756807 11.14114069 -50.908778 262.019 19.290719 -28.31701005 -18.566167 264.267 -37.300387 57.80327828 37.906531 266.516 6.013498 3.91431430 36.645644 268.765 5.989627 -0.06745439 -7.859197 271.015 18.549391 -58.21191799 23.786263 273.267 48.944039 10.01974124 -47.209174 275.519 -20.263275 -17.90984089 -9.783721 277.772 68.158408 -47.30041158 52.205279 attr(,"emission") [1] 244.073 246.313 248.554 250.796 253.039 255.282 257.527 259.773 262.019 [10] 264.267 266.516 268.765 271.015 273.267 275.519 277.772 attr(,"excitation") [1] 700 698 696 694 692 690 688 686 684 682 680 678 676 674 672 attr(,"scale") [1] 1 attr(,"class") [1] "feem" > > f2 <- file(system.file('extdata/panorama.dat', package = 'albatross')) > feem(f2, 'panorama') excitation emission 230 235 240 240 0.5034276 NA NA 241 0.4567109 NA NA 242 0.4221046 NA NA 243 0.3816112 NA NA 244 0.3626316 NA NA 245 0.3325805 0.5664473 NA 246 0.3023371 0.5269381 NA 247 0.2723085 0.4562700 NA 248 0.2694618 0.4256358 NA 249 0.2570733 0.3986036 NA 250 0.2742427 0.3394058 0.5825356 251 0.2515778 0.3153662 0.5221785 252 0.2501180 0.2886578 0.4679464 253 0.2317043 0.2543437 0.4114071 254 0.2260515 0.2260742 0.3766724 255 0.2066508 0.2159555 0.4044045 attr(,"emission") [1] 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 attr(,"excitation") [1] 230 235 240 attr(,"scale") [1] 1 attr(,"class") [1] "feem" > > # must stop on files in wrong format > assertError(feem(ho_aq, 'panorama'), verbose = TRUE) Asserted error: Failed to parse file header > assertError(feem(ho_aq, 'table'), verbose = TRUE) Asserted error: Couldn't parse any numbers inside the file > > # must handle empty Stokes area, too > pano4 <- as.data.frame(feem( + system.file('extdata/pano-Stokes.dat', package = 'albatross'), + 'panorama' + )) > with(pano4, + stopifnot(range(emission - excitation) == c(10, 14)) + ) > > # must handle flipped Panorama files > pano5 <- as.data.frame(feem( + system.file('extdata/pano-flip.dat', package = 'albatross'), + 'panorama' + )) > with(pano5, stopifnot(excitation >= emission + 10)) > > # must handle dec=',' > dcs <- feem( + system.file('extdata/decimal_comma.tsv', package = 'albatross'), + 'table', dec = ',', sep = '\t' + ) > tools::assertError(feem( # must fail with wrong separator + system.file('extdata/decimal_comma.tsv', package = 'albatross'), + 'table', dec = '.', sep = '\t' + ), verbose = TRUE) Asserted error: Couldn't parse any fluorescence intensities in the file > stopifnot( + setequal(attr(dcs, 'excitation'), c(640, 645, 650)), + dim(dcs) == c(5,3), + !is.na(dcs), + min(attr(dcs, 'emission')) < 245, + max(attr(dcs, 'excitation')) > 247 + ) > > proc.time() user system elapsed 0.37 0.12 0.48