Skip to content

Commit

Permalink
feat: include wavelength and retention time information in long tables
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbass committed Nov 17, 2024
1 parent 8c011a1 commit bae5821
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 3 additions & 1 deletion R/reshape_chroms.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified data/pk_tab.RData
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/testthat/test-utility-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
2 changes: 1 addition & 1 deletion vignettes/articles/fid_article.bib
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit bae5821

Please sign in to comment.