From f4c86d907465a150692730dd9b9d9dbe46c17735 Mon Sep 17 00:00:00 2001 From: Arnaud Wolfer Date: Mon, 26 Feb 2024 22:54:26 +0100 Subject: [PATCH] unittest update for ggplot2 --- DESCRIPTION | 8 +++--- inst/NEWS | 2 ++ man/peakPantheR.Rd | 1 - ...nnotation_retentionTimeCorrection-method.R | 2 +- tests/testthat/test_peakPantheR_plotEICFit.R | 12 ++++----- .../testthat/test_peakPantheR_plotPeakwidth.R | 26 +++++++++---------- tests/testthat/test_peakPantheR_quickEIC.R | 4 +-- tests/testthat/test_plotHistogram.R | 6 ++--- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6983396..7d6f95f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: peakPantheR Title: Peak Picking and Annotation of High Resolution Experiments -Version: 1.17.1 -Date: 2023-11-04 +Version: 1.17.2 +Date: 2024-02-26 Authors@R: c(person("Arnaud", "Wolfer", email = "adwolfer@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5856-3218")), person("Goncalo", "Correia", email = "gscorreia89@gmail.com", role = "aut", comment = c(ORCID = "0000-0001-8271-9294")), person("Jake", "Pearce", email = "jake.pearce@gmail.com", role = "ctb"), @@ -14,7 +14,7 @@ Depends: Imports: foreach (>= 1.4.4), doParallel (>= 1.0.11), - ggplot2 (>= 3.3.0), + ggplot2 (>= 3.5.0), gridExtra (>= 2.3), MSnbase (>= 2.4.0), mzR (>= 2.12.0), @@ -37,7 +37,7 @@ BugReports: https://github.com/phenomecentre/peakPantheR/issues/new URL: https://github.com/phenomecentre/peakPantheR Encoding: UTF-8 LazyData: false -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: testthat, devtools, faahKO, diff --git a/inst/NEWS b/inst/NEWS index 32eb60c..a5ed6a1 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,3 +1,5 @@ +Changes in version 1.17.2 (2024-02-26) +- update unittest for `ggplot2` 3.5.0 Changes in version 1.17.1 (2023-11-04) - `peakPantheR_quickEIC()` to plot EIC from raw files - SVG output option for AnnotationDiagnostic summary plot diff --git a/man/peakPantheR.Rd b/man/peakPantheR.Rd index 18ce09e..de66f1f 100644 --- a/man/peakPantheR.Rd +++ b/man/peakPantheR.Rd @@ -3,7 +3,6 @@ \docType{package} \name{peakPantheR} \alias{peakPantheR} -\alias{_PACKAGE} \alias{peakPantheR-package} \title{peakPantheR: A package for Peak Picking and ANnoTation of High resolution Experiments} diff --git a/tests/testthat/test_peakPantheRAnnotation_retentionTimeCorrection-method.R b/tests/testthat/test_peakPantheRAnnotation_retentionTimeCorrection-method.R index cc6ce03..28e8e9a 100644 --- a/tests/testthat/test_peakPantheRAnnotation_retentionTimeCorrection-method.R +++ b/tests/testthat/test_peakPantheRAnnotation_retentionTimeCorrection-method.R @@ -174,7 +174,7 @@ test_that('rt correction plot (uROI)', { expect_equal(length(resultCorrected$result), 2) # plot values expect_equal(resultCorrected$result$plot[[1]], expected_plotFrame, tolerance=1e-6) - expect_equal(length(resultCorrected$result$plot), 9) + expect_equal(length(resultCorrected$result$plot), length(ggplot2::ggplot())) expect_equal(resultCorrected$result$plot$labels$x, 'Retention time') expect_equal(resultCorrected$result$plot$labels$y, 'Retention time deviation') expect_is(resultCorrected$result$plot$layers[[1]]$geom, 'GeomPoint') diff --git a/tests/testthat/test_peakPantheR_plotEICFit.R b/tests/testthat/test_peakPantheR_plotEICFit.R index 0af319a..33b25bf 100644 --- a/tests/testthat/test_peakPantheR_plotEICFit.R +++ b/tests/testthat/test_peakPantheR_plotEICFit.R @@ -38,7 +38,7 @@ test_that('plot feature in 1 sample', { expect_true(ggplot2::is.ggplot(result_plot1SplNoCol)) expect_equal(result_plot1SplNoCol$labels$x, "Retention Time (sec)") expect_equal(result_plot1SplNoCol$labels$y, "Intensity") - expect_equal(length(result_plot1SplNoCol), 9) + expect_equal(length(result_plot1SplNoCol), length(ggplot2::ggplot())) }) test_that('plot feature in 1 sample, no curveFit with warning', { @@ -59,7 +59,7 @@ test_that('plot feature in 1 sample, no curveFit with warning', { expect_true(ggplot2::is.ggplot(result_plot1SplNoFitNoCol$result)) expect_equal(result_plot1SplNoFitNoCol$result$labels$x, "Retention Time (sec)") expect_equal(result_plot1SplNoFitNoCol$result$labels$y, "Intensity") - expect_equal(length(result_plot1SplNoFitNoCol$result), 9) + expect_equal(length(result_plot1SplNoFitNoCol$result), length(ggplot2::ggplot())) }) test_that('plot feature in 2 samples, change colours and sampling', { @@ -73,7 +73,7 @@ test_that('plot feature in 2 samples, change colours and sampling', { expect_true(ggplot2::is.ggplot(result_plot2SplWithCol)) expect_equal(result_plot2SplWithCol$labels$x, "Retention Time (sec)") expect_equal(result_plot2SplWithCol$labels$y, "Intensity") - expect_equal(length(result_plot2SplWithCol), 9) + expect_equal(length(result_plot2SplWithCol), length(ggplot2::ggplot())) }) test_that('plot feature in 2 samples, rtMin and/or rtMax have a NA (cannot plot fit)', { @@ -87,7 +87,7 @@ test_that('plot feature in 2 samples, rtMin and/or rtMax have a NA (cannot plot expect_true(ggplot2::is.ggplot(result_plot2SplRTNA)) expect_equal(result_plot2SplRTNA$labels$x, "Retention Time (sec)") expect_equal(result_plot2SplRTNA$labels$y, "Intensity") - expect_equal(length(result_plot2SplRTNA), 9) + expect_equal(length(result_plot2SplRTNA), length(ggplot2::ggplot())) }) test_that('no rtMin and/or rtMax, cannot plot fit warning', { @@ -107,7 +107,7 @@ test_that('no rtMin and/or rtMax, cannot plot fit warning', { expect_true(ggplot2::is.ggplot(result_plotFitWarning$result)) expect_equal(result_plotFitWarning$result$labels$x, "Retention Time (sec)") expect_equal(result_plotFitWarning$result$labels$y, "Intensity") - expect_equal(length(result_plotFitWarning$result), 9) + expect_equal(length(result_plotFitWarning$result), length(ggplot2::ggplot())) }) test_that('sampleColour length warning', { @@ -128,7 +128,7 @@ test_that('sampleColour length warning', { expect_true(ggplot2::is.ggplot(result_plotColourWarning$result)) expect_equal(result_plotColourWarning$result$labels$x, "Retention Time (sec)") expect_equal(result_plotColourWarning$result$labels$y, "Intensity") - expect_equal(length(result_plotColourWarning$result), 9) + expect_equal(length(result_plotColourWarning$result), length(ggplot2::ggplot())) }) test_that('raise errors', { diff --git a/tests/testthat/test_peakPantheR_plotPeakwidth.R b/tests/testthat/test_peakPantheR_plotPeakwidth.R index e8e4206..f3a5e85 100644 --- a/tests/testthat/test_peakPantheR_plotPeakwidth.R +++ b/tests/testthat/test_peakPantheR_plotPeakwidth.R @@ -22,7 +22,7 @@ test_that('plot 3 samples, no color', { expect_true(ggplot2::is.ggplot(result_3splNoColNoRot)) expect_equal(result_3splNoColNoRot$labels$x, "x") expect_equal(result_3splNoColNoRot$labels$y, "Test variable") - expect_equal(length(result_3splNoColNoRot), 9) + expect_equal(length(result_3splNoColNoRot), length(ggplot2::ggplot())) }) test_that('plot 3 samples, no color, acquisition time', { @@ -35,7 +35,7 @@ test_that('plot 3 samples, no color, acquisition time', { expect_true(ggplot2::is.ggplot(result_3splNoColNoRotRunOrder)) expect_equal(result_3splNoColNoRotRunOrder$labels$x, "Acquisition Time") expect_equal(result_3splNoColNoRotRunOrder$labels$y, "Test variable 2") - expect_equal(length(result_3splNoColNoRotRunOrder), 9) + expect_equal(length(result_3splNoColNoRotRunOrder), length(ggplot2::ggplot())) }) test_that('plot 3 samples, no color, rotate axis', { @@ -48,7 +48,7 @@ test_that('plot 3 samples, no color, rotate axis', { expect_true(ggplot2::is.ggplot(result_3splNoColRot)) expect_equal(result_3splNoColRot$labels$x, "Test variable 3") expect_equal(result_3splNoColRot$labels$y, "x") - expect_equal(length(result_3splNoColRot), 9) + expect_equal(length(result_3splNoColRot), length(ggplot2::ggplot())) }) test_that('plot 3 samples, no color, acquisition time, rotate axis', { @@ -61,7 +61,7 @@ test_that('plot 3 samples, no color, acquisition time, rotate axis', { expect_true(ggplot2::is.ggplot(result_3splNoColRotRunOrder)) expect_equal(result_3splNoColRotRunOrder$labels$x, "Test variable 4") expect_equal(result_3splNoColRotRunOrder$labels$y, "Acquisition Time") - expect_equal(length(result_3splNoColRotRunOrder), 9) + expect_equal(length(result_3splNoColRotRunOrder), length(ggplot2::ggplot())) }) test_that('plot 4 samples with color', { @@ -74,7 +74,7 @@ test_that('plot 4 samples with color', { expect_true(ggplot2::is.ggplot(result_4splWithColNoRot)) expect_equal(result_4splWithColNoRot$labels$x, "x") expect_equal(result_4splWithColNoRot$labels$y, "Test variable 5") - expect_equal(length(result_4splWithColNoRot), 9) + expect_equal(length(result_4splWithColNoRot), length(ggplot2::ggplot())) }) test_that('plot 4 samples with color, acquisition time', { @@ -87,7 +87,7 @@ test_that('plot 4 samples with color, acquisition time', { expect_true(ggplot2::is.ggplot(result_4splWithColNoRotRunOrder)) expect_equal(result_4splWithColNoRotRunOrder$labels$x, "Acquisition Time") expect_equal(result_4splWithColNoRotRunOrder$labels$y, "Test variable 6") - expect_equal(length(result_4splWithColNoRotRunOrder), 9) + expect_equal(length(result_4splWithColNoRotRunOrder), length(ggplot2::ggplot())) }) test_that('plot 4 samples with color, rotate axis', { @@ -100,7 +100,7 @@ test_that('plot 4 samples with color, rotate axis', { expect_true(ggplot2::is.ggplot(result_4splWithColRot)) expect_equal(result_4splWithColRot$labels$x, "Test variable 7") expect_equal(result_4splWithColRot$labels$y, "x") - expect_equal(length(result_4splWithColRot), 9) + expect_equal(length(result_4splWithColRot), length(ggplot2::ggplot())) }) test_that('plot 4 samples with color, acquisition time, rotate axis', { @@ -113,7 +113,7 @@ test_that('plot 4 samples with color, acquisition time, rotate axis', { expect_true(ggplot2::is.ggplot(result_4splWithColRotRunOrder)) expect_equal(result_4splWithColRotRunOrder$labels$x, "Acquisition Time") expect_equal(result_4splWithColRotRunOrder$labels$y, "Test variable 8") - expect_equal(length(result_4splWithColRotRunOrder), 9) + expect_equal(length(result_4splWithColRotRunOrder), length(ggplot2::ggplot())) }) test_that('sampleColour length warning, peakwidth and rotate and input order message', { @@ -132,7 +132,7 @@ test_that('sampleColour length warning, peakwidth and rotate and input order mes expect_true(ggplot2::is.ggplot(result_plotColourWarning$result)) expect_equal(result_plotColourWarning$result$labels$x, "Test variable 9") expect_equal(result_plotColourWarning$result$labels$y, "x") - expect_equal(length(result_plotColourWarning$result), 9) + expect_equal(length(result_plotColourWarning$result), length(ggplot2::ggplot())) }) test_that('sampleColour length warning, no peakwidth (missing widthMax) and no rotate and run order message', { @@ -151,7 +151,7 @@ test_that('sampleColour length warning, no peakwidth (missing widthMax) and no r expect_true(ggplot2::is.ggplot(result_plotColourWarningRunOrder$result)) expect_equal(result_plotColourWarningRunOrder$result$labels$x, "Acquisition Time") expect_equal(result_plotColourWarningRunOrder$result$labels$y, "Test variable 10") - expect_equal(length(result_plotColourWarningRunOrder$result), 9) + expect_equal(length(result_plotColourWarningRunOrder$result), length(ggplot2::ggplot())) }) test_that('missing widthMin, no peakwidth plot', { @@ -170,7 +170,7 @@ test_that('missing widthMin, no peakwidth plot', { expect_true(ggplot2::is.ggplot(result_plotNoWidthMin$result)) expect_equal(result_plotNoWidthMin$result$labels$x, "x") expect_equal(result_plotNoWidthMin$result$labels$y, "Test variable 11") - expect_equal(length(result_plotNoWidthMin$result), 9) + expect_equal(length(result_plotNoWidthMin$result), length(ggplot2::ggplot())) }) test_that('missing widthMax, no peakwidth plot', { @@ -189,7 +189,7 @@ test_that('missing widthMax, no peakwidth plot', { expect_true(ggplot2::is.ggplot(result_plotNoWidthMax$result)) expect_equal(result_plotNoWidthMax$result$labels$x, "x") expect_equal(result_plotNoWidthMax$result$labels$y, "Test variable 11") - expect_equal(length(result_plotNoWidthMax$result), 9) + expect_equal(length(result_plotNoWidthMax$result), length(ggplot2::ggplot())) }) test_that('NA in acquisition time, revert to input order plot', { @@ -208,7 +208,7 @@ test_that('NA in acquisition time, revert to input order plot', { expect_true(ggplot2::is.ggplot(result_plotFallBackNAAcqu$result)) expect_equal(result_plotFallBackNAAcqu$result$labels$x, "x") expect_equal(result_plotFallBackNAAcqu$result$labels$y, "Test variable 12") - expect_equal(length(result_plotFallBackNAAcqu$result), 9) + expect_equal(length(result_plotFallBackNAAcqu$result), length(ggplot2::ggplot())) }) test_that('raise errors', { diff --git a/tests/testthat/test_peakPantheR_quickEIC.R b/tests/testthat/test_peakPantheR_quickEIC.R index 1cc7946..fd9b01f 100644 --- a/tests/testthat/test_peakPantheR_quickEIC.R +++ b/tests/testthat/test_peakPantheR_quickEIC.R @@ -20,7 +20,7 @@ test_that('default plot EIC, subset rt and mz, verbose', { expect_true(ggplot2::is.ggplot(result_peakPantheR_quickEIC$result)) expect_equal(result_peakPantheR_quickEIC$result$labels$x, "Retention Time (sec)") expect_equal(result_peakPantheR_quickEIC$result$labels$y, "Intensity") - expect_equal(length(result_peakPantheR_quickEIC$result), 9) + expect_equal(length(result_peakPantheR_quickEIC$result), length(ggplot2::ggplot())) # Check result messages (reading and timing) expect_equal(length(result_peakPantheR_quickEIC$messages), 3) @@ -35,7 +35,7 @@ test_that('default plot EIC, no verbose', { expect_true(ggplot2::is.ggplot(result_peakPantheR_quickEIC$result)) expect_equal(result_peakPantheR_quickEIC$result$labels$x, "Retention Time (sec)") expect_equal(result_peakPantheR_quickEIC$result$labels$y, "Intensity") - expect_equal(length(result_peakPantheR_quickEIC$result), 9) + expect_equal(length(result_peakPantheR_quickEIC$result), length(ggplot2::ggplot())) # Check result messages (None other than MSnbase) expect_equal(length(result_peakPantheR_quickEIC$messages), 1) diff --git a/tests/testthat/test_plotHistogram.R b/tests/testthat/test_plotHistogram.R index 0f0d8e7..e249bb8 100644 --- a/tests/testthat/test_plotHistogram.R +++ b/tests/testthat/test_plotHistogram.R @@ -32,7 +32,7 @@ test_that('histogram and density, with NA in input', { expect_equal(result_histoAndDensity$labels$x, "Test variable") expect_equal(result_histoAndDensity$labels$y, "density") expect_equal(result_histoAndDensity$data, expected_data) - expect_equal(length(result_histoAndDensity), 9) + expect_equal(length(result_histoAndDensity), length(ggplot2::ggplot())) # Check message (warning is caught as result and not warning!?!) expect_equal(result_message$messages, expected_message) @@ -50,7 +50,7 @@ test_that('histogram without density', { expect_equal(result_histoNoDensity$labels$x, "Test variable 2") expect_equal(result_histoNoDensity$labels$y[1], "count") expect_equal(result_histoNoDensity$data, expected_data) - expect_equal(length(result_histoNoDensity), 9) + expect_equal(length(result_histoNoDensity), length(ggplot2::ggplot())) }) test_that('histogram and density with modified ... (bins)', { @@ -71,5 +71,5 @@ test_that('histogram and density with modified ... (bins)', { expect_equal(result_histoChangeBins$labels$x, "Test variable 3") expect_equal(result_histoChangeBins$labels$y, "density") expect_equal(result_histoChangeBins$data, expected_data) - expect_equal(length(result_histoChangeBins), 9) + expect_equal(length(result_histoChangeBins), length(ggplot2::ggplot())) })