diff --git a/DESCRIPTION b/DESCRIPTION index acd1ee8..599dfdd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,13 @@ Depends: R (>= 4.3) Imports: dplyr, gridExtra, stringr, stats, ggplot2, stringi, grDevices, MSstatsTMT, MSstatsConvert, MSstats, data.table, Rcpp, Biostrings, checkmate, ggrepel -Suggests: knitr, rmarkdown, tinytest, covr +Suggests: + knitr, + rmarkdown, + tinytest, + covr, + mockery, + testthat (>= 3.0.0) LazyData: true LinkingTo: Rcpp VignetteBuilder: knitr @@ -33,3 +39,4 @@ BugReports: https://github.com/Vitek-Lab/MSstatsPTM/issues Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 +Config/testthat/edition: 3 diff --git a/R/utils_dataProcessPlots.R b/R/utils_dataProcessPlots.R index c74df44..05bd6cd 100644 --- a/R/utils_dataProcessPlots.R +++ b/R/utils_dataProcessPlots.R @@ -89,9 +89,6 @@ ## Adjust colnames to avoid repeating code for (i in seq_along(data.list)) { colnames(data.list[[i]]) = toupper(colnames(data.list[[i]])) - if ('INTENSITY' %in% colnames(data.list[[i]])){ - data.list[[i]]$ABUNDANCE = log2(data.list[[i]]$INTENSITY) - } setnames(data.list[[i]], c('LOGINTENSITIES', 'GROUP', 'PROTEIN', 'Protein', 'LOG2INTENSITY'), c('ABUNDANCE', 'CONDITION', 'PROTEINNAME', 'PROTEINNAME', @@ -1755,4 +1752,4 @@ if (address != FALSE) { dev.off() } -} \ No newline at end of file +} diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..9276dbd --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,13 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(mockery) +library(MSstatsPTM) + +test_check("MSstatsPTM") diff --git a/tests/testthat/test_dataProcessPlotsPTM.R b/tests/testthat/test_dataProcessPlotsPTM.R new file mode 100644 index 0000000..87ca44d --- /dev/null +++ b/tests/testthat/test_dataProcessPlotsPTM.R @@ -0,0 +1,19 @@ +test_that("Medians are equalized in ptm data to QC plot helper function", { + mock_qc_all_plot_lf <- mock() + stub( + dataProcessPlotsPTM, ".qc.all.plot.lf", + mock_qc_all_plot_lf, depth=2 + ) + + dataProcessPlotsPTM(summary.data, + type = 'QCPLOT', + which.PTM = "allonly", + address = FALSE) + + calls <- mock_args(mock_qc_all_plot_lf) + ptm_data <- calls[[1]][[1]] + run_data = split(ptm_data, ptm_data$RUN) + for (i in 1:length(run_data)){ + expect_equal(median(run_data[[i]]$ABUNDANCE, na.rm = TRUE), 22.028431) + } +})