Skip to content

Commit

Permalink
Merge branch 'master' into SNplot_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hechth authored Oct 30, 2024
2 parents 40512d6 + e73eb0a commit 792b88f
Show file tree
Hide file tree
Showing 27 changed files with 32 additions and 12 deletions.
12 changes: 10 additions & 2 deletions R/IsoFiltR.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ]
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/test-IsoFiltR.R
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-MFAssign.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 11 additions & 7 deletions tests/testthat/test-RecalFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
})

Expand All @@ -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)
},
Expand Down
Binary file modified tests/testthat/test-data/21_qc_no_dil_milliq_iso.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/bug_recal_expected.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_ambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_cho_ambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_cho_none.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_cho_unambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_iso.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_none.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_recal_iso.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_recal_mono.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_recallist.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/neg_unambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_ambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_cho_ambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_cho_none.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_cho_unambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_iso.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_none.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_recal_iso.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_recal_mono.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/pos_unambig.rds
Binary file not shown.
Binary file modified tests/testthat/test-data/recal_isopeaks.rds
Binary file not shown.

0 comments on commit 792b88f

Please sign in to comment.