Skip to content

Commit fa98638

Browse files
committed
CI: add tests for Shimadzu tables
1 parent da2447a commit fa98638

File tree

3 files changed

+88
-6
lines changed

3 files changed

+88
-6
lines changed

R/read_peaklist.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ read_peaklist <- function(paths, find_files,
106106
data <- lapply(seq_along(data), function(i){
107107
if (inherits(data[[i]], "list")){
108108
lapply(data[[i]], function(xx){
109-
cbind(Sample = file_names[i], xx)
109+
cbind(sample = file_names[i], xx)
110110
})
111111
} else {
112-
cbind(Sample = file_names[i], data[[i]])
112+
cbind(sample = file_names[i], data[[i]])
113113
}
114114
})
115115
class(data) <- "peak_list"

tests/testthat/test-extra.R

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,38 @@ test_that("read_chroms can read 'Shimadzu' PDA files (ASCII and LCD)", {
592592
round(attr(x2, "time_range"), 3))
593593
})
594594

595+
test_that("Shimadzu Anthocyanin peak tables match", {
596+
skip_on_cran()
597+
skip_if_not_installed("chromConverterExtraTests")
598+
599+
path_ascii <- system.file("shimadzuDAD_Anthocyanin.txt",
600+
package = "chromConverterExtraTests")
601+
skip_if_not(file.exists(path_ascii))
602+
603+
path_lcd <- system.file("Anthocyanin.lcd",
604+
package = "chromConverterExtraTests")
605+
skip_if_not(file.exists(path_lcd))
606+
607+
x <- read_peaklist(path_ascii, format_in = "shimadzu_dad",
608+
data_format = "original",
609+
progress_bar = FALSE)[[1]]
610+
611+
x1 <- read_shimadzu_lcd(path_lcd, what="peak_table")
612+
x1 <- read_peaklist(path_lcd, format_in = "shimadzu_lcd", progress_bar=FALSE)[[1]]
613+
614+
expect_equal(x[[1]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[1]][,-1], tolerance=.001,
615+
ignore_attr=TRUE)
616+
expect_equal(x[[2]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[3]][,-1], tolerance=.001,
617+
ignore_attr=TRUE)
618+
expect_equal(x[[3]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[4]][,-1], tolerance=.001,
619+
ignore_attr=TRUE)
620+
expect_equal(x[[4]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[5]][,-1], tolerance=.001,
621+
ignore_attr=TRUE)
622+
expect_equal(x[[5]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[6]][,-1], tolerance=.001,
623+
ignore_attr=TRUE)
624+
})
625+
626+
595627
test_that("read_chroms can read 2D chromatograms from 'Shimadzu' LCD files", {
596628
skip_on_cran()
597629
skip_if_not_installed("chromConverterExtraTests")
@@ -729,6 +761,36 @@ test_that("read_chroms can read multi-channel chromatograms from 'Shimadzu' LCD
729761
expect_equal(x2[x2$lambda == "", "intensity"], x[["B"]], ignore_attr = TRUE)
730762
})
731763

764+
test_that("Shimadzu multichannel peak tables match", {
765+
skip_on_cran()
766+
skip_if_not_installed("chromConverterExtraTests")
767+
768+
path_asc <- system.file("multichannel_chrom.txt",
769+
package = "chromConverterExtraTests")
770+
771+
skip_if_not(file.exists(path_asc))
772+
773+
path_lcd <- system.file("multichannel_chrom.lcd",
774+
package = "chromConverterExtraTests")
775+
skip_if_not(file.exists(path_lcd))
776+
777+
x <- read_peaklist(path_asc, format_in = "shimadzu_dad",
778+
data_format = "original",
779+
progress_bar = FALSE)[[1]]
780+
781+
x1 <- read_peaklist(path_lcd, format_in = "shimadzu_lcd",
782+
progress_bar=FALSE)[[1]]
783+
784+
785+
expect_equal(x[[1]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[1]][,-1], tolerance=.01,
786+
ignore_attr=TRUE)
787+
expect_equal(x[[2]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[2]][,-1], tolerance=.001,
788+
ignore_attr=TRUE)
789+
expect_equal(x[[3]][,c(3,6:7,4:5,8:9,11,13:18,21:22)],x1[[3]][,-1], tolerance=.001,
790+
ignore_attr=TRUE)
791+
})
792+
793+
732794
test_that("read_chroms can read 'Agilent' .dx files", {
733795
skip_on_cran()
734796
skip_if_not_installed("chromConverterExtraTests")
@@ -874,6 +936,26 @@ test_that("Shimadzu GCD parser works", {
874936
expect_equal(as.numeric(attr(txt, "time_range")), round(attr(x, "time_range"), 3))
875937
})
876938

939+
test_that("Shimadzu FID peak tables match", {
940+
skip_on_cran()
941+
skip_if_not_installed("chromConverterExtraTests")
942+
943+
path_asc <- test_path("testdata/ladder.txt")
944+
945+
path_gcd <- system.file("FS19_214.gcd", package = "chromConverterExtraTests")
946+
skip_if_not(file.exists(path_gcd))
947+
948+
x <- read_peaklist(path_asc, format_in = "shimadzu_dad",
949+
data_format = "original",
950+
progress_bar = FALSE)[[1]]
951+
952+
x1 <- read_peaklist(path_gcd, format_in = "shimadzu_gcd", progress_bar=FALSE)
953+
954+
expect_equal(x[,c(3,6:7,4:5,8:9,11,13:18,21:22)], x1[[1]][,-1], tolerance=.001,
955+
ignore_attr=TRUE)
956+
})
957+
958+
877959
test_that("Shimadzu QGD parser works", {
878960
skip_on_cran()
879961
skip_if_missing_dependencies()

tests/testthat/test-read_chroms.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ test_that("read_peaklist can read `Shimadzu` fid files", {
298298
expect_equal(x[[1]][[1,"sample"]], "ladder")
299299
expect_equal(x[[1]][[1,"sample"]], "ladder")
300300
expect_equal(colnames(x[[1]]),
301-
c("sample","Peak.","R.Time","I.Time","F.Time","Area","Height",
302-
"A.H","Conc.","Mark","ID.","Name", "k.", "Plate..", "Plate.Ht.",
303-
"Tailing", "Resolution", "Sep.Factor", "Area.Ratio", "Height.Ratio",
304-
"Conc...", "Norm.Conc."))
301+
c("sample","Peak#","R.Time","I.Time","F.Time","Area","Height",
302+
"A/H","Conc.","Mark","ID#","Name", "k'", "Plate #", "Plate Ht.",
303+
"Tailing", "Resolution", "Sep.Factor", "Area Ratio", "Height Ratio",
304+
"Conc. %", "Norm Conc."))
305305
expect_equal(attr(x, "class"), "peak_list")
306306
})
307307

0 commit comments

Comments
 (0)