Skip to content

Commit

Permalink
updated unsupervised test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hechth committed Sep 15, 2022
1 parent c381268 commit feecc56
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/testthat/test-unsupervised.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
patrick::with_parameters_test_that("basic unsupervised test", {
test_files <- sapply(files, function(x) file.path("../testdata/input", x))

expected <- arrow::read_parquet(file.path("../testdata/recovered", paste0(.test_name, ".parquet")))
expected <- arrow::read_parquet(file.path("../testdata/unsupervised", paste0(.test_name, "_unsupervised.parquet")))

result <- unsupervised(test_files, cluster = get_num_workers())
keys <- c("mz", "rt", "sample", "sample_rt", "sample_intensity")
actual <- result$recovered_feature_sample_table

levels(actual$sample) <- sapply(files, get_sample_name)
actual <- actual |> dplyr::arrange_at(keys)
expected <- expected |> dplyr::arrange_at(keys)
# levels(actual$sample) <- sapply(files, get_sample_name)
# actual <- actual |> dplyr::arrange_at(keys)
# expected <- expected |> dplyr::arrange_at(keys)

actual_to_compare <- dplyr::select(actual, keys)
expected_to_compare <- dplyr::select(expected, keys)
# actual_to_compare <- dplyr::select(actual, keys)
# expected_to_compare <- dplyr::select(expected, keys)

report <- dataCompareR::rCompare(actual, expected, keys = keys, roundDigits = 3, mismatches = 100000)
dataCompareR::saveReport(report, reportName = paste0(.test_name,"_unsupervised_report"), showInViewer = FALSE, HTMLReport = FALSE, mismatchCount = 10000)

expect_equal(actual_to_compare, expected_to_compare, tolerance = 0.01)
expect_equal(actual, expected, tolerance = 0.01)
}, patrick::cases(
mbr_test = list(files = c("mbr_test0.mzml", "mbr_test1.mzml", "mbr_test2.mzml")),
RCX_shortened = list(files = c("RCX_06_shortened.mzML", "RCX_07_shortened.mzML", "RCX_08_shortened.mzML"))
Expand Down

0 comments on commit feecc56

Please sign in to comment.