[85ff8e]: / tests / testthat / test-biomarkertmle.R

Download this file

41 lines (34 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(dplyr)
library(biotmleData)
library(SuperLearner)
library(SummarizedExperiment)
data(illuminaData)
## SETUP TESTS ################################################################
colData(illuminaData) <- colData(illuminaData) %>%
data.frame() %>%
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,
bppar_type = BiocParallel::SerialParam(),
g_lib = c("SL.mean", "SL.glm"),
Q_lib = c("SL.mean", "SL.glm")
)
## 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 consistently stores input example data", {
expect_equal(
assay(biomarkerTMLEout)[1, c(17, 83, 117)],
assay(illuminaData)[1, c(17, 83, 117)],
)
})
test_that("biomarkertmle output returns IC estimate for each subject", {
expect_equal(ncol(assay(biomarkerTMLEout)), ncol(illuminaData))
})