diff --git a/R/IsoFiltR.R b/R/IsoFiltR.R index d0b5dfa..c3be79f 100644 --- a/R/IsoFiltR.R +++ b/R/IsoFiltR.R @@ -47,7 +47,7 @@ create_data_chunks <- function(data1) { data_chunks <- list() for (i in 1:10) { - start_idx <- (i - 1) * sect + 1 + start_idx <- max((i-1)*sect, 1) end_idx <- min((i * sect + over), nrow(data1)) data_chunks[[i]] <- data1[start_idx:end_idx, ] } @@ -204,6 +204,14 @@ IsoFiltR <- function( IsoOutC2_final <- unique(IsoOutC2_final) MonoOutC_final <- unique(MonoOutC_final) + dummy <- data.frame(Exp_mass = -42, Abundance = -42, RT = -42) + + IsoOutC1_final <- rbind(IsoOutC1_final, dummy) + IsoOutC2_final <- rbind(IsoOutC2_final, dummy) + MonoOutC_final <- rbind(MonoOutC_final, dummy) + MonoOutS_final <- rbind(MonoOutS_final, dummy) + IsoOutS_final <- rbind(IsoOutS_final, dummy) + IsoOutC1_final$Tag <- "C13" IsoOutC2_final$Tag <- "2C13" MonoOutC_final$Tag <- "C" @@ -465,7 +473,7 @@ process_sulfur <- function(raw_data, sulferr, data_end, sulfrat) { normalization_factor = 12, multiplier = 2, pair_thresold = c(-1.990, -2), - filter_criteria = c(0.00149, -0.29051, -0.29349, 0.70949, 0.7075) + filter_criteria = c(0.00249, -0.29051, -0.29349, 0.70949, 0.7075) ) data_end2 <- data_end diff --git a/changelog.txt b/changelog.txt index cc004ad..ebff952 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ Package Updates +10/30/2024 Version 1.1.2 + - aligned IsoFiltR function with upstream version [#70](https://github.com/RECETOX/MFAssignR/pull/70) + 09/12/2024 Version 1.1.1 - quick fix of hardcoded paths and imports [#59](https://github.com/RECETOX/MFAssignR/pull/59) diff --git a/tests/testthat/test-IsoFiltR.R b/tests/testthat/test-IsoFiltR.R index 06460a4..2e53bf0 100644 --- a/tests/testthat/test-IsoFiltR.R +++ b/tests/testthat/test-IsoFiltR.R @@ -1,8 +1,14 @@ +update_expected <- function(actual, expected_path) { + saveRDS(actual, file = expected_path) +} + patrick::with_parameters_test_that("IsoFiltR works", { raw <- read.csv(file.path("test-data", paste0("QC1_1_", toupper(mode), "_500.csv"))) actual <- IsoFiltR(raw) - expected <- readRDS(file.path("test-data", paste0(mode, "_iso.rds"))) + expected_path <- file.path("test-data", paste0(mode, "_iso.rds")) + expected <- readRDS(expected_path) + expect_equal(actual, expected) }, mode = c("pos", "neg") @@ -20,7 +26,6 @@ test_that("IsoFiltR works on recetox-aplcms output", { patrick::with_parameters_test_that("filtered_data_is_empty works", { expect_equal(filtered_data_is_empty(test_data), expected) - }, patrick::cases( empty = list(test_data=list(content=c()), expected=TRUE), diff --git a/tests/testthat/test-MFAssign.R b/tests/testthat/test-MFAssign.R index 097e9ef..0558edb 100644 --- a/tests/testthat/test-MFAssign.R +++ b/tests/testthat/test-MFAssign.R @@ -15,7 +15,7 @@ load_expected <- function(mode) { )) } -save_expected <- function(actual, mode) { +update_expected <- function(actual, mode) { paths <- expected_paths(mode) saveRDS(actual$Unambig, paths$unambig) saveRDS(actual$Ambig, paths$ambig) diff --git a/tests/testthat/test-RecalFunctions.R b/tests/testthat/test-RecalFunctions.R index a321d72..29248b5 100644 --- a/tests/testthat/test-RecalFunctions.R +++ b/tests/testthat/test-RecalFunctions.R @@ -46,23 +46,24 @@ patrick::with_parameters_test_that("RecalList works", unambig <- readRDS(file.path("test-data", paste0(mode, "_cho_unambig.rds"))) actual <- MFAssignR::RecalList(unambig) + expected <- readRDS(expected_path) actual <- actual %>% dplyr::select(-"Series.Index") expected <- expected %>% dplyr::select(-"Series.Index") actual_sorted <- dplyr::arrange_at(actual, "Series") expected_sorted <- dplyr::arrange_at(expected, "Series") - + expect_equal(actual_sorted, expected_sorted) }, mode = c("neg", "pos"), ) test_that("Replicate the Recal bug", { - unambig <- read.delim("test-data/bug_unambig.tabular") - mono <- read.delim("test-data/bug_mono.tabular") - iso <- read.delim("test-data/bug_iso.tabular") - recallist <- read.delim("test-data/bug_recalseries.tabular") + unambig <- read.delim(file.path("test-data", "bug_unambig.tabular")) + mono <- read.delim(file.path("test-data", "bug_mono.tabular")) + iso <- read.delim(file.path("test-data", "bug_iso.tabular")) + recallist <- read.delim(file.path("test-data", "bug_recalseries.tabular")) actual <- MFAssignR::Recal( df = unambig, @@ -80,7 +81,8 @@ test_that("Replicate the Recal bug", { mzRange = 50, CalPeak = 150 ) - expected <- readRDS("test-data/bug_recal_expected.rds") + expected_path <- file.path("test-data", "bug_recal_expected.rds") + expected <- readRDS(expected_path) expect_equal(actual, expected) }) @@ -102,7 +104,9 @@ patrick::with_parameters_test_that("Replicate Recal isopeaks error", { series5 = recallist$Series[5], mzRange = 80 ) - expected <- readRDS("test-data/recal_isopeaks.rds") + expected_path <- file.path("test-data", "recal_isopeaks.rds") + + expected <- readRDS(expected_path) expect_equal(actual, expected) }, diff --git a/tests/testthat/test-data/21_qc_no_dil_milliq_iso.rds b/tests/testthat/test-data/21_qc_no_dil_milliq_iso.rds index 2676c59..8e95741 100644 Binary files a/tests/testthat/test-data/21_qc_no_dil_milliq_iso.rds and b/tests/testthat/test-data/21_qc_no_dil_milliq_iso.rds differ diff --git a/tests/testthat/test-data/bug_recal_expected.rds b/tests/testthat/test-data/bug_recal_expected.rds index 65a07c9..14a2af5 100644 Binary files a/tests/testthat/test-data/bug_recal_expected.rds and b/tests/testthat/test-data/bug_recal_expected.rds differ diff --git a/tests/testthat/test-data/neg_ambig.rds b/tests/testthat/test-data/neg_ambig.rds index ff2575c..91e05d6 100644 Binary files a/tests/testthat/test-data/neg_ambig.rds and b/tests/testthat/test-data/neg_ambig.rds differ diff --git a/tests/testthat/test-data/neg_cho_ambig.rds b/tests/testthat/test-data/neg_cho_ambig.rds index ca70664..d9be32e 100644 Binary files a/tests/testthat/test-data/neg_cho_ambig.rds and b/tests/testthat/test-data/neg_cho_ambig.rds differ diff --git a/tests/testthat/test-data/neg_cho_none.rds b/tests/testthat/test-data/neg_cho_none.rds index 13f24bb..9528aba 100644 Binary files a/tests/testthat/test-data/neg_cho_none.rds and b/tests/testthat/test-data/neg_cho_none.rds differ diff --git a/tests/testthat/test-data/neg_cho_unambig.rds b/tests/testthat/test-data/neg_cho_unambig.rds index 82362fb..5019b48 100644 Binary files a/tests/testthat/test-data/neg_cho_unambig.rds and b/tests/testthat/test-data/neg_cho_unambig.rds differ diff --git a/tests/testthat/test-data/neg_iso.rds b/tests/testthat/test-data/neg_iso.rds index 0bbff1a..ca2ce40 100644 Binary files a/tests/testthat/test-data/neg_iso.rds and b/tests/testthat/test-data/neg_iso.rds differ diff --git a/tests/testthat/test-data/neg_none.rds b/tests/testthat/test-data/neg_none.rds index 90595aa..679b618 100644 Binary files a/tests/testthat/test-data/neg_none.rds and b/tests/testthat/test-data/neg_none.rds differ diff --git a/tests/testthat/test-data/neg_recal_iso.rds b/tests/testthat/test-data/neg_recal_iso.rds index 4461b27..9ee89cf 100644 Binary files a/tests/testthat/test-data/neg_recal_iso.rds and b/tests/testthat/test-data/neg_recal_iso.rds differ diff --git a/tests/testthat/test-data/neg_recal_mono.rds b/tests/testthat/test-data/neg_recal_mono.rds index 9872025..74294c5 100644 Binary files a/tests/testthat/test-data/neg_recal_mono.rds and b/tests/testthat/test-data/neg_recal_mono.rds differ diff --git a/tests/testthat/test-data/neg_recallist.rds b/tests/testthat/test-data/neg_recallist.rds index b0cfcdc..8e309cc 100644 Binary files a/tests/testthat/test-data/neg_recallist.rds and b/tests/testthat/test-data/neg_recallist.rds differ diff --git a/tests/testthat/test-data/neg_unambig.rds b/tests/testthat/test-data/neg_unambig.rds index adf6061..53c274f 100644 Binary files a/tests/testthat/test-data/neg_unambig.rds and b/tests/testthat/test-data/neg_unambig.rds differ diff --git a/tests/testthat/test-data/pos_ambig.rds b/tests/testthat/test-data/pos_ambig.rds index ff2575c..91e05d6 100644 Binary files a/tests/testthat/test-data/pos_ambig.rds and b/tests/testthat/test-data/pos_ambig.rds differ diff --git a/tests/testthat/test-data/pos_cho_ambig.rds b/tests/testthat/test-data/pos_cho_ambig.rds index 89ac85a..d9be32e 100644 Binary files a/tests/testthat/test-data/pos_cho_ambig.rds and b/tests/testthat/test-data/pos_cho_ambig.rds differ diff --git a/tests/testthat/test-data/pos_cho_none.rds b/tests/testthat/test-data/pos_cho_none.rds index 339ba7e..a6d244e 100644 Binary files a/tests/testthat/test-data/pos_cho_none.rds and b/tests/testthat/test-data/pos_cho_none.rds differ diff --git a/tests/testthat/test-data/pos_cho_unambig.rds b/tests/testthat/test-data/pos_cho_unambig.rds index b0833b0..6dc933a 100644 Binary files a/tests/testthat/test-data/pos_cho_unambig.rds and b/tests/testthat/test-data/pos_cho_unambig.rds differ diff --git a/tests/testthat/test-data/pos_iso.rds b/tests/testthat/test-data/pos_iso.rds index b3d4334..75fb9bc 100644 Binary files a/tests/testthat/test-data/pos_iso.rds and b/tests/testthat/test-data/pos_iso.rds differ diff --git a/tests/testthat/test-data/pos_none.rds b/tests/testthat/test-data/pos_none.rds index 63dab38..3915aa2 100644 Binary files a/tests/testthat/test-data/pos_none.rds and b/tests/testthat/test-data/pos_none.rds differ diff --git a/tests/testthat/test-data/pos_recal_iso.rds b/tests/testthat/test-data/pos_recal_iso.rds index 7f5f3cc..354555c 100644 Binary files a/tests/testthat/test-data/pos_recal_iso.rds and b/tests/testthat/test-data/pos_recal_iso.rds differ diff --git a/tests/testthat/test-data/pos_recal_mono.rds b/tests/testthat/test-data/pos_recal_mono.rds index 77fc633..f9d20ea 100644 Binary files a/tests/testthat/test-data/pos_recal_mono.rds and b/tests/testthat/test-data/pos_recal_mono.rds differ diff --git a/tests/testthat/test-data/pos_unambig.rds b/tests/testthat/test-data/pos_unambig.rds index cad5537..3fea46a 100644 Binary files a/tests/testthat/test-data/pos_unambig.rds and b/tests/testthat/test-data/pos_unambig.rds differ diff --git a/tests/testthat/test-data/recal_isopeaks.rds b/tests/testthat/test-data/recal_isopeaks.rds index 6613971..6720430 100644 Binary files a/tests/testthat/test-data/recal_isopeaks.rds and b/tests/testthat/test-data/recal_isopeaks.rds differ