RECETOX / recetox-xMSannotator

This is a custom adaptation of the original version of xMSannotator. It is a complete rewrite of the original functionality, following the same program structure.
GNU General Public License v3.0
5 stars 5 forks source link

fix tests #99

Closed hechth closed 1 year ago

hechth commented 1 year ago

The tests are currently failing due to differences in the expected outputs. this should be investigated.

xtrojak commented 1 year ago

Wrap occurrences of (is.na(adduct_weights)) with any to avoid the following error:

Error (test_advanced_annotation.R:14:3): basic advanced_annotation functionality
Error in `if (is.na(adduct_weights)) {
    adduct_weights <- data.frame(Adduct = c("M+H", "M-H"), Weight = c(1,
        1))
}`: the condition has length > 1
Backtrace:
 1. recetox.xmsannotator::advanced_annotation(...)
      at test_advanced_annotation.R:14:2
 2. recetox.xmsannotator:::multilevelannotationstep3(...)
      at xmsannotator/R/advanced_annotation.R:173:2

This has direct influence on tests: test-multilevelannotationstep3, test_advanced_annotation.

xtrojak commented 1 year ago

Test test_get_chemscore - Compute chemscore can be called isolated failing

`actual` (`actual`) not equal to `expected` (`expected`)
xtrojak commented 1 year ago

Test test_integration_utils failing for all test cases on:

`actual` is a character vector ('Mean relative difference: 0.04715015')
`expected` is a logical vector (TRUE)
xtrojak commented 1 year ago

Test multilevelannotationstep2 failing for cases: sourceforge

`actual` (`actual`) not equal to `expected` (`expected`).
xtrojak commented 1 year ago

Test test-multilevelannotationstep3.R failing for cases: sourceforge

cannot open file '/tmp/RtmpbFdj7Q/multilevelannotationstep3/qc_solvent/test-data/batch1_neg/Stage3.csv': No such file or directory
xtrojak commented 1 year ago
Error (test_advanced_annotation.R:14:3): basic advanced_annotation functionality
Error in `if (!is.na(filter.by)) {
    check_adduct <- which(curdata$Adduct %in% filter.by)
    if (length(check_adduct) <= 0) {
        bool_check <- 0
    }
}`: the condition has length > 1
Backtrace:
 1. recetox.xmsannotator::advanced_annotation(...)
      at test_advanced_annotation.R:14:2
 2. recetox.xmsannotator:::multilevelannotationstep4(...)
      at xmsannotator/R/advanced_annotation.R:182:2
 3. base::lapply(...)
      at xmsannotator/R/multilevelannotationstep4.R:170:4
 4. recetox.xmsannotator (local) FUN(X[[i]], ...)
xtrojak commented 1 year ago
Error in `if (Confidence < 2) {
    if (length(which(curdata$Adduct %in% adduct_weights[which(as.numeric(adduct_weights[, 
        2]) > 0), 1])) > 0) {
        if (curdata$score > 10) {
            mnum <- max(as.numeric(as.character(adduct_weights[which(adduct_weights[, 
                1] %in% curdata$Adduct), 2])))[1]
            curdata <- curdata[which(curdata$Adduct %in% adduct_weights[which(as.numeric(as.character(adduct_weights[, 
                2])) >= mnum), 1]), ]
            Confidence <- 2
        }
    }
}`: the condition has length > 1
Backtrace:
 1. rlang::eval_tidy(code, args)
 2. recetox.xmsannotator:::multilevelannotationstep4(...)
      at test-multilevelannotationstep4.R:32:4
 3. base::lapply(...)
      at xmsannotator/R/multilevelannotationstep4.R:170:4
 4. recetox.xmsannotator (local) FUN(X[[i]], ...)
xtrojak commented 1 year ago

Seems like most of the errors can be actually traced to compute_confidence_levels function, which does not work if curdata has multiple rows. This is most probably caused by the change in behaviour of if conditions between R version under and above 4.