[28e211]: / tests / testthat / test-DIscBIO-CTCs-Binder-Part2.R

Download this file

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