Skip to content

Commit

Permalink
feat: support Sz LCD/GCD tables in read_peaklist
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Dec 21, 2024
1 parent 10792b0 commit da2447a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
21 changes: 15 additions & 6 deletions R/read_peaklist.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#' the function with a folder or vector of folders containing the files.
#' Otherwise, set to\code{FALSE}.
#' @param format_in Format of files to be imported/converted. Current options
#' include: \code{chemstation} or \code{shimadzu}.
#' include: \code{chemstation}, \code{shimadzu_fid}, \code{shimadzu_dad},
#' \code{shimadzu_lcd}, and \code{shimadzu_gcd}.
#' @param pattern pattern (e.g. a file extension). Defaults to NULL, in which
#' case file extension will be deduced from \code{format_in}.
#' @param data_format Either \code{chromatographr} or \code{original}.
Expand All @@ -33,14 +34,16 @@

read_peaklist <- function(paths, find_files,
format_in = c("chemstation", "shimadzu_fid",
"shimadzu_dad"),
"shimadzu_dad", "shimadzu_lcd",
"shimadzu_gcd"),
pattern = NULL,
data_format = c("chromatographr", "original"),
metadata_format = c("chromconverter", "raw"),
read_metadata = TRUE, progress_bar, cl = 1){
data_format <- match.arg(tolower(data_format), c("chromatographr", "original"))
format_in <- match.arg(tolower(format_in),
c("chemstation", "shimadzu_fid", "shimadzu_dad"))
c("chemstation", "shimadzu_fid", "shimadzu_dad",
"shimadzu_lcd", "shimadzu_gcd"))
if (missing(progress_bar)){
progress_bar <- check_for_pkg("pbapply", return_boolean = TRUE)
}
Expand All @@ -62,12 +65,18 @@ read_peaklist <- function(paths, find_files,
parser <- purrr::partial(read_chemstation_reports,
data_format = data_format,
metadata_format = metadata_format)
} else if (grepl("shimadzu", format_in)){
} else if (format_in %in% c("shimadzu_dad", "shimadzu_fid")){
pattern <- ifelse(is.null(pattern), ".txt", pattern)
parser <- partial(read_shimadzu, what = "peak_table",
data_format = "wide",
read_metadata = read_metadata,
peaktable_format = data_format)
} else if (format_in == "shimadzu_lcd"){
parser <- partial(read_shimadzu_lcd, what = "peak_table",
data_format="wide", read_metadata=read_metadata)
} else if (format_in == "shimadzu_gcd"){
parser <- partial(read_shimadzu_gcd, what = "peak_table",
data_format="wide", read_metadata=read_metadata)
}

if (find_files){
Expand Down Expand Up @@ -97,10 +106,10 @@ read_peaklist <- function(paths, find_files,
data <- lapply(seq_along(data), function(i){
if (inherits(data[[i]], "list")){
lapply(data[[i]], function(xx){
cbind(sample = file_names[i], xx)
cbind(Sample = file_names[i], xx)
})
} else {
cbind(sample = file_names[i], data[[i]])
cbind(Sample = file_names[i], data[[i]])
}
})
class(data) <- "peak_list"
Expand Down
4 changes: 2 additions & 2 deletions R/read_shimadzu_ascii.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ read_shimadzu_peaktable <- function(path, x, idx, sep, format_in, format_out){
t1 <- strsplit(x = x[[table_start + 3]], split = sep)[[1]][time_column]
decimal_separator <- ifelse(grepl(",", t1), ",", ".")

peak_tab <- read.csv(path, skip = table_start-1, sep = sep, nrows = nrows,
dec = decimal_separator)
peak_tab <- read.csv(path, skip = (table_start-1), sep = sep, nrows = nrows,
dec = decimal_separator, check.names = FALSE)
if (format_out == "chromatographr"){
column_names <- switch(format_in, "MC" = c("Ret.Time", "Proc.From",
"Proc.To", "Area", "Height"),
Expand Down
6 changes: 4 additions & 2 deletions man/read_peaklist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da2447a

Please sign in to comment.