tests/testthat/test-TDI.R

context("Test: TDI() ")

data(DivergenceExpressionSetExample)


nonStandardExpressionSet <- DivergenceExpressionSetExample[, 2:9]

test_that("is.ExpressionSet() throughs error when no ExpressionSet is entered to TDI()",
          {
                  expect_error(
                          TDI(nonStandardExpressionSet)
                  )
          })


testTAIFunc <- function(ExpressionSet) {
        ncols <- ncol(ExpressionSet)
        TAIVals <- vector("numeric", ncols - 2)
        
        for (i in 1:(ncols - 2)) {
                TAIVals[i] <-
                        sum((ExpressionSet[, 1] * ExpressionSet[, i + 2]) / sum(ExpressionSet[, i +
                                                                                                      2]))
        }
        
        names(TAIVals) <- names(ExpressionSet)[3:ncols]
        
        return(TAIVals)
}


test_that("TDI() computes correct values ", {
        expect_equal(
                TDI(DivergenceExpressionSetExample),
                testTAIFunc(DivergenceExpressionSetExample)
        )
})

Try the myTAI package in your browser

Any scripts or data that you put into this service are public.

myTAI documentation built on May 23, 2018, 5:03 p.m.