|
a |
|
b/tests/testthat/test-rnaseq.R |
|
|
1 |
library(SummarizedExperiment) |
|
|
2 |
library(biotmleData) |
|
|
3 |
data(illuminaData) |
|
|
4 |
|
|
|
5 |
## SETUP TESTS ################################################################ |
|
|
6 |
set.seed(6423709) |
|
|
7 |
n <- 50 |
|
|
8 |
g <- 2500 |
|
|
9 |
cases_pois <- 50 |
|
|
10 |
controls_pois <- 10 |
|
|
11 |
|
|
|
12 |
ngs_cases <- as.data.frame(matrix(replicate(n, rpois(g, cases_pois)), g)) |
|
|
13 |
ngs_controls <- as.data.frame(matrix(replicate(n, rpois(g, controls_pois)), g)) |
|
|
14 |
|
|
|
15 |
ngs_data <- as.data.frame(cbind(ngs_cases, ngs_controls)) |
|
|
16 |
exp_var <- c(rep(1, n), rep(0, n)) |
|
|
17 |
batch <- rep(1:2, n) |
|
|
18 |
covar <- rep(1, n * 2) |
|
|
19 |
design <- as.data.frame(cbind(exp_var, batch, covar)) |
|
|
20 |
|
|
|
21 |
se <- SummarizedExperiment( |
|
|
22 |
assays = list(counts = DataFrame(ngs_data)), |
|
|
23 |
colData = DataFrame(design) |
|
|
24 |
) |
|
|
25 |
call <- "testing" # dumb workaround to failure of match.call() for now... |
|
|
26 |
class(call) <- "call" # force class to be what biotmle expects... |
|
|
27 |
|
|
|
28 |
biotmle <- .biotmle( |
|
|
29 |
SummarizedExperiment( |
|
|
30 |
assays = list(expMeasures = assay(se)), |
|
|
31 |
rowData = rowData(se), |
|
|
32 |
colData = colData(se) |
|
|
33 |
), |
|
|
34 |
call = call, |
|
|
35 |
tmleOut = as.data.frame(matrix(NA, 10, 10)), |
|
|
36 |
topTable = as.data.frame(matrix(NA, 10, 10)) |
|
|
37 |
) |
|
|
38 |
voom_out <- rnaseq_ic(biotmle) |
|
|
39 |
|
|
|
40 |
## BEGIN TESTS ################################################################ |
|
|
41 |
test_that("Object returned by RNA-seq tools matches output of voom", { |
|
|
42 |
expect_is(voom_out, "EList") |
|
|
43 |
}) |
|
|
44 |
|
|
|
45 |
test_that("Object returned by RNA-seq tools is of correct dimensionality", { |
|
|
46 |
expect_equal(dim(voom_out), c(g, 2 * n)) |
|
|
47 |
}) |