diff --git a/NEWS.md b/NEWS.md index 40d4ff2a..87d1cca8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +#chromatographR 0.7.3 + +* Updated `reshape_peaktable` function to include wavelength and retention time data. +* Updated `pk_tab` data file to latest peak table format. + # chromatographR 0.7.2 * Export `get_times` and `get_lambdas` functions. diff --git a/R/reshape_chroms.R b/R/reshape_chroms.R index ab756207..792ee83d 100644 --- a/R/reshape_chroms.R +++ b/R/reshape_chroms.R @@ -99,7 +99,9 @@ reshape_peaktable <- function(x, peaks, metadata, fixed_levels = TRUE){ times = colnames(df), timevar = "peak", idvar = "sample", ids = rownames(df)) rownames(xx) <- NULL - xx <- xx[,c(3,1,2)] + xx <- merge(xx, data.frame(peak=colnames(x$pk_meta), t(x$pk_meta[c("lambda","rt"),])), + by="peak",all.x=TRUE) + xx <- xx[, c(1, 3, 4, 5, 2)] if (!is.null(dim(x$sample_meta))){ xx <- merge(xx, data.frame(sample = row.names(df), x$sample_meta), by = "sample", all.x = TRUE) diff --git a/data/pk_tab.RData b/data/pk_tab.RData index cab65079..233b46cd 100644 Binary files a/data/pk_tab.RData and b/data/pk_tab.RData differ diff --git a/tests/testthat/test-utility-functions.R b/tests/testthat/test-utility-functions.R index 13609ff1..bc647f56 100644 --- a/tests/testthat/test-utility-functions.R +++ b/tests/testthat/test-utility-functions.R @@ -118,11 +118,11 @@ test_that("reshape_peaktable works as expected",{ pk_tab <- attach_metadata(pk_tab, metadata = meta, column = "vial") pktab_long <- reshape_peaktable(pk_tab) - expect_equal(ncol(pktab_long), 3 + ncol(pk_tab$sample_meta)) + expect_equal(ncol(pktab_long), 5 + ncol(pk_tab$sample_meta)) expect_equal(nrow(pktab_long), nrow(pk_tab)*ncol(pk_tab)) pktab_long <- reshape_peaktable(pk_tab, peaks = c("V51","V60"), metadata = "trt") - expect_equal(ncol(pktab_long), 3 + 1) + expect_equal(ncol(pktab_long), 5 + 1) expect_equal(nrow(pktab_long), nrow(pk_tab)*2) }) diff --git a/vignettes/articles/fid_article.bib b/vignettes/articles/fid_article.bib index 5c9fb04c..19e2d44a 100644 --- a/vignettes/articles/fid_article.bib +++ b/vignettes/articles/fid_article.bib @@ -119,7 +119,7 @@ @article{legan2021 @article{legan2022, title = {Molecular and {{Chemical Basis}} of {{Social Olfaction}} in {{Polistes Paper Wasps}}}, - author = {Legan, Andrew Wesley}, + author = {Legan, Andrew W.}, date = {2022}, publisher = {Cornell University Library}, doi = {10.7298/CZ0P-6J74}