Skip to content

Commit

Permalink
unittest update for ggplot2
Browse files Browse the repository at this point in the history
  • Loading branch information
adwolfer committed Feb 26, 2024
1 parent 6611151 commit f4c86d9
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5856-3218")),
person("Goncalo", "Correia", email = "[email protected]", role = "aut", comment = c(ORCID = "0000-0001-8271-9294")),
person("Jake", "Pearce", email = "[email protected]", role = "ctb"),
Expand All @@ -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),
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion man/peakPantheR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test_peakPantheR_plotEICFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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', {
Expand All @@ -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)', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand Down
26 changes: 13 additions & 13 deletions tests/testthat/test_peakPantheR_plotPeakwidth.R
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand All @@ -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', {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_peakPantheR_quickEIC.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_plotHistogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)', {
Expand All @@ -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()))
})

0 comments on commit f4c86d9

Please sign in to comment.