|
a |
|
b/tests/testthat/test-DIscBIO-CTCs-Binder-Part1.R |
|
|
1 |
if (interactive()) { |
|
|
2 |
context("Binder tests, part 1") |
|
|
3 |
|
|
|
4 |
# Defining the relative path to current inst --------------------------------- |
|
|
5 |
notebook_data_path <- system.file("notebook", package = "DIscBIO") |
|
|
6 |
FileName <- "CTCdataset" |
|
|
7 |
load(file.path(notebook_data_path, paste0(FileName, ".rda"))) |
|
|
8 |
load(file.path(notebook_data_path, "SC.RData")) |
|
|
9 |
load(file.path(notebook_data_path, "Ndata.RData")) |
|
|
10 |
load(file.path(notebook_data_path, "expdata.RData")) |
|
|
11 |
DataSet <- get(FileName) |
|
|
12 |
|
|
|
13 |
test_that("Loading CTC dataset", { |
|
|
14 |
expect_equal(length(DataSet[, 1]), 13181) |
|
|
15 |
expect_equal(length(DataSet[1, ]), 1462) |
|
|
16 |
}) |
|
|
17 |
|
|
|
18 |
sc <- DISCBIO(DataSet) |
|
|
19 |
S1 <- summary(colSums(DataSet, na.rm = TRUE)) |
|
|
20 |
S2 <- summary(rowMeans(DataSet, na.rm = TRUE)) |
|
|
21 |
minexpr <- S2[3] |
|
|
22 |
minnumber <- round(length(DataSet[1, ]) / 10) |
|
|
23 |
|
|
|
24 |
test_that("Handling datasets", { |
|
|
25 |
expect_true(is(sc, "DISCBIO")) |
|
|
26 |
expect_output(str(S1), " 'summaryDefault' Named num") |
|
|
27 |
expect_equal(minnumber, 146) |
|
|
28 |
}) |
|
|
29 |
|
|
|
30 |
sc <- Normalizedata( |
|
|
31 |
sc, |
|
|
32 |
minexpr = minexpr, minnumber = minnumber, rseed = 17000 |
|
|
33 |
) |
|
|
34 |
sc <- suppressMessages(FinalPreprocessing(sc, GeneFlitering = "ExpF")) |
|
|
35 |
sc <- SC |
|
|
36 |
sc@ndata <- Ndata |
|
|
37 |
sc@expdata <- expdata |
|
|
38 |
|
|
|
39 |
# Removing the unneeded objects |
|
|
40 |
rm(Ndata) |
|
|
41 |
rm(expdata) |
|
|
42 |
rm(DataSet) |
|
|
43 |
rm(SC) |
|
|
44 |
gc() |
|
|
45 |
|
|
|
46 |
long_test <- FALSE # switching to true runs slow tests below |
|
|
47 |
if (long_test) { |
|
|
48 |
sc <- Clustexp(sc, 4, bootnr = 2, B.gap = 2, quiet = TRUE, rseed = 17000) |
|
|
49 |
outlg <- round(length(sc@fdata[, 1]) * 0.05) |
|
|
50 |
Outliers <- FindOutliers(sc, 4, outlg = outlg, plot = FALSE, quiet = TRUE) |
|
|
51 |
jcrd <- Jaccard(sc, K = 4, plot = FALSE, R = 2) |
|
|
52 |
sc <- pseudoTimeOrdering(sc, quiet = TRUE) |
|
|
53 |
|
|
|
54 |
test_that("Post-processing", { |
|
|
55 |
expect_equivalent(jcrd, c(.422, .649, .335, .605)) |
|
|
56 |
expect_output( |
|
|
57 |
object = str(sc, max.level = 1), |
|
|
58 |
expected = 'Formal class \'DISCBIO\' [package "DIscBIO"] with 21 slots' |
|
|
59 |
) |
|
|
60 |
}) |
|
|
61 |
} |
|
|
62 |
} |