Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing isCentroidedFromFile unit test #338

Closed
lgatto opened this issue Apr 19, 2018 · 5 comments
Closed

Failing isCentroidedFromFile unit test #338

lgatto opened this issue Apr 19, 2018 · 5 comments

Comments

@lgatto
Copy link
Owner

lgatto commented Apr 19, 2018

The last unit test in test_centroided.R currently fails with

* checking tests ...
  Running ‘testthat.R’
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
    my description
   10 features of interest:
     P20353, P53501  ...  Q9VCK0, Q9VIU7
  A collection of 1 features of interest.
  A collection of 10 features of interest.
  reading dummyiTRAQ.mzid... DONE!
  Iterations of EM: 
  1...2...3...4...5...6...7...8...9...10...11...
  [1] 0.07947339
  ....══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 2010 SKIPPED: 8 FAILED: 1
  1. Failure: isCentroidedFromFile (@test_centroided.R#33) 
  
  Error: testthat unit tests failed
  Execution halted

See also https://master.bioconductor.org/checkResults/3.7/bioc-LATEST/MSnbase/malbec2-checksrc.html

I have issues reproducing this interactively.

@jotsetung - could you have a go, please.

@jorainer
Copy link
Collaborator

I can also not reproduce it. I tested with MSnbase 2.5.14 (current master). For version 2.5.13 (checked out from Bioc git) I get:

> baseUrl <- "https://raw.githubusercontent.com/HUPO-PSI/mzTab/master/examples/"
> 
> ## a list of mzTab objects
> mzt <- sapply(file.path(baseUrl, fls), MzTab)
Warning in file(con, "r") :
  cannot open URL 'https://raw.githubusercontent.com/HUPO-PSI/mzTab/master/examples//Cytidine.mzTab': HTTP status was '404 Not Found'
Error in file(con, "r") : 
  cannot open the connection to 'https://raw.githubusercontent.com/HUPO-PSI/mzTab/master/examples//Cytidine.mzTab'
Calls: sapply -> sapply -> lapply -> FUN -> readLines -> file
Execution halted
* checking for unstated dependencies intests... OK
* checking tests ...
  Runningtestthat.RERROR
Running the tests intests/testthat.Rfailed.
Last 13 lines of output:
   - 131.1382 +/- 0.002 (#BC80BD)
  Object of class "Spectrum1"
   Retention time: 0:0 
   MSn level: 1 
   Total ion count: 684 
   Polarity: 1 
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 1974 SKIPPED: 8 FAILED: 4
  1. Error: fileNames accessor MzTab (@test_fileNames.R#10) 
  2. Error: read MzTab data v 0.9 and 1.0 (@test_MzTab_09.R#8) 
  3. Error: MzTab creation and accessors (@test_MzTab.R#8) 
  4. Error: Conversion to MSnSetList (@test_MzTab.R#34) 
  
  Error: testthat unit tests failed
  Execution halted

but no error in the test_centroided.R

@lgatto
Copy link
Owner Author

lgatto commented Apr 20, 2018

These errors you observe come from remote files that have unexpectedly changed location - this has been fixed on github. Thank you for testing.

@jorainer
Copy link
Collaborator

the only thing I've seen is that lines 27 and 33 produce warnings - eventually there is a limit in the number of allowed warnings in unit tests on the BioC build machines?
we could actually wrap these calls into expect_warning (because in fact we expect that a warning is thrown, since one of the two files does not provide any centroiding information):

expect_warning(cnt <- isCentroidedFromFile(microtofq_on_disk))
expect_identical(names(cnt), featureNames(microtofq_on_disk))
##
## subsetting
k <- sort(sample(length(microtofq_on_disk), 10))
xx <- microtofq_on_disk[k]
expect_warning(expect_identical(isCentroidedFromFile(xx), cnt[k]))

@jorainer
Copy link
Collaborator

I think I found the reason for the error:

library("testthat")
library("MSnbase")
f <- c(system.file("microtofq/MM14.mzML", package = "msdata"),
       system.file("microtofq/MM8.mzML", package = "msdata"))
microtofq_on_disk <- readMSData(f, mode = "onDisk")

cnt <- isCentroidedFromFile(microtofq_on_disk)

## For the first file centroiding information can be determined:
head(cnt)
F1.S001 F1.S002 F1.S003 F1.S004 F1.S005 F1.S006 
   TRUE    TRUE    TRUE    TRUE    TRUE    TRUE 

## But for the second not:
tail(cnt)
F2.S193 F2.S194 F2.S195 F2.S196 F2.S197 F2.S198 
     NA      NA      NA      NA      NA      NA

## If k represents indices of spectra from the first and the second file it works:
k <- c(1:5, 300:305)
xx <- microtofq_on_disk[k]
expect_identical(isCentroidedFromFile(xx), cnt[k])

## But if k represents indices of spectra only of the second file:
k <- 300:310
xx <- microtofq_on_disk[k]
expect_identical(isCentroidedFromFile(xx), cnt[k])
Error: isCentroidedFromFile(xx) not identical to cnt[k].
Names: 'is.NA' value mismatch: 0 in current 11 in target
In addition: Warning message:
In .isCentroidedFromFile(f) : NAs introduced by coercion

Summarizing, the solution would be to add set.seed(123) before k <- sort(sample(length(microtofq_on_disk), 10)), or to use:

expect_identical(unname(isCentroidedFromFile(xx)), unname(cnt[k]))

@lgatto
Copy link
Owner Author

lgatto commented Apr 20, 2018

Thank you!

@lgatto lgatto closed this as completed Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants