|
a |
|
b/tests/testthat/test-DIscBIO-CTCs-Binder-Part2.R |
|
|
1 |
if (interactive()) { |
|
|
2 |
# ======================================================== # |
|
|
3 |
# Loading and rearranging files # |
|
|
4 |
# ======================================================== # |
|
|
5 |
|
|
|
6 |
notebook_data_path <- system.file("notebook", package = "DIscBIO") |
|
|
7 |
load(file.path(notebook_data_path, "SC.RData")) |
|
|
8 |
load(file.path(notebook_data_path, "Ndata.RData")) |
|
|
9 |
load(file.path(notebook_data_path, "expdata.RData")) |
|
|
10 |
load(file.path(notebook_data_path, "DATAforDT.RData")) |
|
|
11 |
|
|
|
12 |
sc <- SC |
|
|
13 |
sc@ndata <- Ndata |
|
|
14 |
sc@expdata <- expdata |
|
|
15 |
|
|
|
16 |
rm(Ndata) |
|
|
17 |
rm(expdata) |
|
|
18 |
rm(SC) |
|
|
19 |
|
|
|
20 |
# ======================================================== # |
|
|
21 |
# differential expression analysis # |
|
|
22 |
# ======================================================== # |
|
|
23 |
|
|
|
24 |
context("Binder tests, part 2: Differential expression analysis") |
|
|
25 |
|
|
|
26 |
cdiff <- DEGanalysis2clust(sc, 4, quiet = TRUE, plot = FALSE) |
|
|
27 |
|
|
|
28 |
test_that("DEG analysis between 2 clusters", { |
|
|
29 |
expect_equal( |
|
|
30 |
object = head(cdiff[[1]])[, 1], |
|
|
31 |
expected = c( |
|
|
32 |
"ENSG00000008988", "ENSG00000010278", "ENSG00000034510", |
|
|
33 |
"ENSG00000071082", "ENSG00000071127", "ENSG00000075624" |
|
|
34 |
) |
|
|
35 |
) |
|
|
36 |
expect_equal( |
|
|
37 |
object = head(cdiff[[1]])[, 2], |
|
|
38 |
expected = c("RPS20", "CD9", "TMSB10", "RPL31", "WDR1", "ACTB") |
|
|
39 |
) |
|
|
40 |
expect_equivalent( |
|
|
41 |
object = as.character(head(cdiff[[2]])[1, ]), |
|
|
42 |
expected = c( |
|
|
43 |
"CL1 VS CL2", "CL2", "106", "Up-regulated-NameCL2inCL1VSCL2.csv", |
|
|
44 |
"82", "Low-regulated-NameCL2inCL1VSCL2.csv" |
|
|
45 |
) |
|
|
46 |
) |
|
|
47 |
expect_equal( |
|
|
48 |
object = as.character(head(cdiff[[2]])[2, ]), |
|
|
49 |
expected = c( |
|
|
50 |
"CL1 VS CL2", "CL1", "106", "Low-regulated-NameCL1inCL1VSCL2.csv", |
|
|
51 |
"82", "Up-regulated-NameCL1inCL1VSCL2.csv" |
|
|
52 |
) |
|
|
53 |
) |
|
|
54 |
}) |
|
|
55 |
|
|
|
56 |
cdiffBinomial <- ClustDiffGenes(sc, 4, quiet = TRUE) |
|
|
57 |
|
|
|
58 |
test_that("Cluster differences", { |
|
|
59 |
expect_equal( |
|
|
60 |
object = head(cdiffBinomial[[1]])[, 1], |
|
|
61 |
expected = c( |
|
|
62 |
"ENSG00000001630", "ENSG00000002586", "ENSG00000003402", |
|
|
63 |
"ENSG00000003436", "ENSG00000003756", "ENSG00000004059" |
|
|
64 |
) |
|
|
65 |
) |
|
|
66 |
expect_equal( |
|
|
67 |
object = head(cdiffBinomial[[1]])[, 2], |
|
|
68 |
expected = c("CYP51A1", "CD99", "CFLAR", "TFPI", "RBM5", "ARF5") |
|
|
69 |
) |
|
|
70 |
expect_equivalent( |
|
|
71 |
object = as.character(head(cdiffBinomial[[2]])[1, ]), |
|
|
72 |
expected = c( |
|
|
73 |
"Cluster 1", "Remaining Clusters", "1052", "Up-DEG-cluster1.csv", |
|
|
74 |
"678", "Down-DEG-cluster1.csv" |
|
|
75 |
) |
|
|
76 |
) |
|
|
77 |
expect_equal( |
|
|
78 |
object = as.character(head(cdiffBinomial[[2]])[2, ]), |
|
|
79 |
expected = c( |
|
|
80 |
"Cluster 2", "Remaining Clusters", "0", "Up-DEG-cluster2.csv", "1", |
|
|
81 |
"Down-DEG-cluster2.csv" |
|
|
82 |
) |
|
|
83 |
) |
|
|
84 |
}) |
|
|
85 |
|
|
|
86 |
|
|
|
87 |
# ======================================================== # |
|
|
88 |
# Decision trees # |
|
|
89 |
# ======================================================== # |
|
|
90 |
|
|
|
91 |
context("Binder tests, part 2: Decision trees") |
|
|
92 |
|
|
|
93 |
j48dt <- J48DT(DATAforDT, plot = FALSE, quiet = TRUE) |
|
|
94 |
rpartDT <- RpartDT(DATAforDT, plot = FALSE, quiet = TRUE) |
|
|
95 |
|
|
|
96 |
test_that("J48 trees", { |
|
|
97 |
expect_true(is(summary(j48dt), "Weka_classifier_evaluation")) |
|
|
98 |
expect_output(str(rpartDT), "List of 14") |
|
|
99 |
}) |
|
|
100 |
|
|
|
101 |
# ======================================================== # |
|
|
102 |
# Networking # |
|
|
103 |
# ======================================================== # |
|
|
104 |
|
|
|
105 |
context("Binder tests, part 2: Networking") |
|
|
106 |
|
|
|
107 |
data <- cdiffBinomial[[1]][1:200, 2] # only the firat 200 genes |
|
|
108 |
ppi <- suppressMessages(PPI(data)) |
|
|
109 |
networking <- suppressMessages(NetAnalysis(ppi)) |
|
|
110 |
|
|
|
111 |
test_that("Networks", { |
|
|
112 |
expect_gt(nrow(ppi), 1000) |
|
|
113 |
expect_equal(ncol(ppi), 13) |
|
|
114 |
expect_gt(nrow(networking), 150) |
|
|
115 |
expect_equal(ncol(networking), 3) |
|
|
116 |
}) |
|
|
117 |
} |