tests/testthat/test-biomarkertmle.R

context("biomarkertmle estimation function.")
library(dplyr)
library(biotmleData)
library(SuperLearner)
library(SummarizedExperiment)
data(illuminaData)

## SETUP TESTS #################################################################
colData(illuminaData) <- colData(illuminaData) %>%
  data.frame() %>%
  dplyr::mutate(age = as.numeric(age > median(age))) %>%
  DataFrame()
varInt_index <- which(names(colData(illuminaData)) %in% "benzene")

biomarkerTMLEout <- biomarkertmle(
  se = illuminaData[1:2, ],
  varInt = varInt_index,
  parallel = FALSE,
  g_lib = c("SL.mean", "SL.glm"),
  Q_lib = "SL.mean"
)

## BEGIN TESTS #################################################################
test_that("biomarkertmle output object is of class type S4", {
  expect_equivalent(typeof(biomarkerTMLEout), "S4")
})

test_that("biomarkertmle object is of appropriate custom class", {
  expect_equivalent(class(biomarkerTMLEout), "bioTMLE")
})

test_that("biomarkertmle output is consistent using example data", {
  expect_equal(
    assay(biomarkerTMLEout)[1, c(17, 83, 117)],
    c(360.7073, 375.9316, 319.3649)
  )
})

test_that("biomarkertmle output returns IC estimate for each subject", {
  expect_equal(ncol(assay(biomarkerTMLEout)), ncol(illuminaData))
})

Try the biotmle package in your browser

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

biotmle documentation built on Nov. 8, 2020, 5:10 p.m.