Skip to content

Commit 7f1fc6e

Browse files
committed
more fix tests and warnings
1 parent 0301b6b commit 7f1fc6e

4 files changed

Lines changed: 27 additions & 28 deletions

File tree

tests/testthat/test_MSnExpFilters.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,8 @@ test_that("filterMz", {
149149
test_that("filterPrecursorScan", {
150150
expect_error(filterPrecursorScan(inmem1, 1),
151151
"column\\(s\\) acquisitionNum/precursorScanNum is/are missing")
152-
expect_true(all.equal(ondisk[1:11], filterPrecursorScan(ondisk, 1003)))
153-
expect_true(all.equal(ondisk[c(1:11, 19:20)],
154-
filterPrecursorScan(ondisk, c(1003, 1022))))
155-
expect_true(all.equal(ondisk[NA], filterPrecursorScan(ondisk, 1)))
152+
expect_true(all.equal(ondisk[1003:1013], filterPrecursorScan(ondisk, 1003)))
153+
expect_true(all.equal(ondisk[1], filterPrecursorScan(ondisk, 1)))
156154
})
157155

158156

tests/testthat/test_Spectrum.R

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ test_that("Noise estimation", {
9090
test_that("Peak picking", {
9191
s1 <- new("Spectrum2", mz = 1:5, intensity = c(1:3, 2:1))
9292
s2 <- new("Spectrum2", mz = 3, intensity = 3, centroided = TRUE)
93-
expect_warning(pickPeaks(new("Spectrum2")), "spectrum is empty")
94-
expect_equal(suppressWarnings(pickPeaks(new("Spectrum2"))),
93+
expect_warning(MSnbase::pickPeaks(new("Spectrum2")), "spectrum is empty")
94+
expect_equal(suppressWarnings(MSnbase::pickPeaks(new("Spectrum2"))),
9595
new("Spectrum2"))
96-
expect_equal(suppressWarnings(pickPeaks(s2)), s2)
96+
expect_equal(suppressWarnings(MSnbase::pickPeaks(s2)), s2)
9797
centroided(s1) <- FALSE
98-
expect_equal(pickPeaks(s1), s2)
99-
expect_equal(pickPeaks(s1, msLevel = 1), s1)
100-
expect_equal(pickPeaks(s1, msLevel = c(2, 3)), s2)
98+
expect_equal(MSnbase::pickPeaks(s1), s2)
99+
expect_equal(MSnbase::pickPeaks(s1, msLevel. = 1), s1)
100+
expect_equal(MSnbase::pickPeaks(s1, msLevel. = c(2, 3)), s2)
101101
})
102102

103103
test_that("Spectrum smoothing", {
104104
s1 <- new("Spectrum2", mz = 1:5, intensity = c(1:3, 2:1))
105105
s2 <- new("Spectrum2", mz = 1:5, intensity = c(2, 2, 2+1/3, 2, 2))
106106
expect_warning(smooth(new("Spectrum2")), "spectrum is empty")
107107
expect_equal(smooth(s1, method = "MovingAverag", halfWindowSize = 1), s2)
108-
expect_equal(smooth(s1, msLevel = 1), s1)
108+
expect_equal(smooth(s1, msLevel. = 1), s1)
109109
})
110110

111111
test_that("Spectrum quantification", {
@@ -121,7 +121,7 @@ test_that("Spectrum quantification", {
121121
mz = mz,
122122
centroided = FALSE)
123123
expect_true(validObject(sp))
124-
expect_equal(getCurveWidth(sp, iTRAQ4[1]),
124+
expect_equal(MSnbase:::getCurveWidth(sp, iTRAQ4[1]),
125125
list(lwr = 1, upr = 5))
126126
expect_equal(as.numeric(quantify(sp, "sum", iTRAQ4[1])$peakQuant), 6)
127127
expect_equal(as.numeric(quantify(sp, "max", iTRAQ4[1])$peakQuant), 3)
@@ -189,27 +189,27 @@ test_that(".fix_breaks works as breaks_Spectra", {
189189
brks <- seq(floor(min(c(mz(s1), mz(s1)))),
190190
ceiling(max(c(mz(s1), mz(s1)))), by = 1)
191191
expect_equal(brks, 1:4)
192-
expect_equal(.fix_breaks(brks, c(1, 4)), 1:5)
192+
expect_equal(MSnbase:::.fix_breaks(brks, c(1, 4)), 1:5)
193193
brks <- seq(floor(min(c(mz(s1), mz(s2)))),
194194
ceiling(max(c(mz(s1), mz(s2)))), by = 1)
195195
expect_equal(brks, 1:5)
196196
## issue 190
197-
expect_equal(.fix_breaks(brks, c(1, 5)), 1:6)
197+
expect_equal(MSnbase:::.fix_breaks(brks, c(1, 5)), 1:6)
198198
brks <- seq(floor(min(c(mz(s1), mz(s2)))),
199199
ceiling(max(c(mz(s1), mz(s2)))), by = 2)
200200
expect_equal(brks, c(1, 3, 5))
201-
expect_equal(.fix_breaks(brks, c(1, 6)), c(1, 3, 5, 7))
202-
201+
expect_equal(MSnbase:::.fix_breaks(brks, c(1, 6)), c(1, 3, 5, 7))
202+
##
203203
s3 <- new("Spectrum2", mz = 1:4, intensity = 1:4)
204204
s4 <- new("Spectrum2", mz = 11:15, intensity = 1:5)
205205
brks <- seq(floor(min(c(mz(s3), mz(s4)))),
206206
ceiling(max(c(mz(s3), mz(s4)))), by = 1)
207207
expect_equal(brks, 1:15)
208-
expect_equal(.fix_breaks(brks, c(1, 15)), 1:16)
208+
expect_equal(MSnbase:::.fix_breaks(brks, c(1, 15)), 1:16)
209209
brks <- seq(floor(min(c(mz(s3), mz(s4)))),
210210
ceiling(max(c(mz(s3), mz(s4)))), by = 2)
211211
expect_equal(brks, seq(1, 15, 2))
212-
expect_equal(.fix_breaks(brks, c(1, 15)), seq(1, 17, by=2))
212+
expect_equal(MSnbase:::.fix_breaks(brks, c(1, 15)), seq(1, 17, by=2))
213213
})
214214

215215
test_that("bin_Spectrum", {
@@ -294,7 +294,7 @@ test_that("empty spectrum", {
294294
test_that("show MS1 spectrum", {
295295
f <- dir(system.file("threonine", package = "msdata"),
296296
full.names = TRUE)
297-
x <- readMSData(f, msLevel = 1)
297+
x <- readMSData(f, msLevel. = 1)
298298
expect_null(show(x[[1]]))
299299
})
300300

@@ -315,7 +315,7 @@ test_that(".spectrum_header works", {
315315
"scanWindowLowerLimit", "scanWindowUpperLimit"))]
316316
for (cn in cns)
317317
expect_equal(hdr[1, cn], hdr_1[1, cn])
318-
hdr_2 <- .spectrum_header(sp_2)
318+
hdr_2 <- MSnbase:::.spectrum_header(sp_2)
319319
hdr_2$seqNum <- 1L
320320
expect_true(all(colnames(hdr) %in%
321321
c("electronBeamEnergy", colnames(hdr_2))))
@@ -329,19 +329,19 @@ test_that("kNeighbors works", {
329329
mzs <- 1:length(ints) + rnorm(length(ints), mean = 0, sd = 0.1)
330330
plot(mzs, ints, type = "h")
331331
pk_pos <- c(4, 8, 12)
332-
332+
##
333333
res <- kNeighbors(mzs, ints, peakIdx = pk_pos, k = 1)
334334
points(res[, 1], res[, 2], type = "h", col = "blue")
335335
expect_equal(unname(res[1, 1]), weighted.mean(mzs[3:5], ints[3:5]))
336336
expect_equal(unname(res[2, 1]), weighted.mean(mzs[7:9], ints[7:9]))
337337
expect_equal(unname(res[3, 1]), weighted.mean(mzs[11:13], ints[11:13]))
338-
338+
##
339339
res <- kNeighbors(mzs, ints, peakIdx = pk_pos, k = 2)
340340
points(res[, 1], res[, 2], type = "h", col = "green")
341341
expect_equal(unname(res[1, 1]), weighted.mean(mzs[2:6], ints[2:6]))
342342
expect_equal(unname(res[2, 1]), weighted.mean(mzs[6:10], ints[6:10]))
343343
expect_equal(unname(res[3, 1]), weighted.mean(mzs[10:14], ints[10:14]))
344-
344+
##
345345
expect_error(kNeighbors(mz = 3, ints))
346346
})
347347

@@ -470,7 +470,7 @@ test_that(".estimate_mz_scattering works", {
470470
expect_true(length(res) == 1)
471471
expect_true(res < 0.051)
472472
expect_error(.estimate_mz_scattering(mzs))
473-
473+
##
474474
all_mz <- c(mzs + rnorm(length(mzs), sd = 0.01),
475475
mzs + rnorm(length(mzs), sd = 0.005),
476476
mzs + rnorm(length(mzs), sd = 0.06))
@@ -659,4 +659,4 @@ test_that("consensusSpectrum works", {
659659
res_1 <- consensusSpectrum(spl, mzd = 0.02, mzFun = max, weighted = TRUE)
660660
res_2 <- consensusSpectrum(spl, mzd = 0.02, weighted = TRUE)
661661
expect_identical(mz(res_1), mz(res_2))
662-
})
662+
})

tests/testthat/test_centroided.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ test_that("centroided accessor with/without na.fail", {
66
## in-mem, experiment
77
expect_true(all(centroided(x)))
88
## on-disk, single spectrum
9-
expect_true(!centroided(x2[[1]]))
10-
expect_true(centroided(x2[[2]]))
9+
expect_true(!centroided(x2[[1]])) ## MS1
10+
expect_true(centroided(x2[[227]])) ## MS2
1111
## on-disk, experiment
1212
expect_true(all(!centroided(filterMsLevel(x2, 1))))
1313
expect_true(all(centroided(filterMsLevel(x2, 2))))

tests/testthat/test_options.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test_that("setMSnbaseFastLoad works", {
2+
setMSnbaseFastLoad()
23
orig_value <- MSnbaseOptions()$fastLoad
34
setMSnbaseFastLoad(!orig_value)
45
expect_equal(MSnbaseOptions()$fastLoad, !orig_value)
@@ -7,10 +8,10 @@ test_that("setMSnbaseFastLoad works", {
78
})
89

910
test_that("isMSnbaseFastLoad works", {
11+
setMSnbaseFastLoad()
1012
orig_value <- MSnbaseOptions()$fastLoad
1113
expect_equal(isMSnbaseFastLoad(), orig_value)
1214
setMSnbaseFastLoad(!orig_value)
1315
expect_equal(isMSnbaseFastLoad(), !orig_value)
1416
setMSnbaseFastLoad(orig_value)
1517
})
16-

0 commit comments

Comments
 (0)