[ea2224]: / tests / testthat / test-full-tests.R

Download this file

170 lines (141 with data), 4.5 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# This extends tests in test-basic-workflow.R
# Skip these tests on CRAN
skip_on_cran()
xe <- XenaGenerate(subset = grepl("BRCA", XenaCohorts))
xe2 <- XenaHub(hostName = "tcgaHub")
xe3 <- XenaHub(
hosts = "https://tcga.xenahubs.net",
cohorts = "TCGA Breast Cancer (BRCA)",
datasets = "TCGA.BRCA.sampleMap/HiSeqV2"
)
all_hosts <- c(
"https://ucscpublic.xenahubs.net",
"https://tcga.xenahubs.net",
"https://gdc.xenahubs.net",
"https://gdcV18.xenahubs.net",
"https://icgc.xenahubs.net",
"https://toil.xenahubs.net",
"https://pancanatlas.xenahubs.net",
"https://xena.treehouse.gi.ucsc.edu:443",
"https://pcawg.xenahubs.net",
"https://atacseq.xenahubs.net",
"https://singlecellnew.xenahubs.net",
"https://kidsfirst.xenahubs.net",
"https://tdi.xenahubs.net"
)
# XenaHub-class.R ---------------------------------------------------------
test_that("show method for XenaHub object works", {
expect_output(show(xe), "class: XenaHub")
})
test_that("fun xena_default_hosts works", {
expect_identical(xena_default_hosts(), all_hosts)
})
test_that("fun XenaHub works", {
expect_output(show(xe2), "class: XenaHub")
expect_error(XenaHub(hostName = "xxx"))
expect_output(show(xe3), "class: XenaHub")
})
test_that("fun .collapse_list works", {
expect_identical(.collapse_list(c("a", "b")), "a,b")
})
# api-higher --------------------------------------------------------------
test_that("funs to get hosts, cohorts, datasets and samples work", {
expect_identical("https://tcga.xenahubs.net", hosts(xe3))
expect_identical("TCGA Breast Cancer (BRCA)", cohorts(xe3))
expect_identical("TCGA.BRCA.sampleMap/HiSeqV2", datasets(xe3))
samples <- samples(xe3)[[1]]
expect_true("TCGA-GI-A2C8-01" %in% samples)
})
# Fetch -------------------------------------------------------------------
host <- "https://toil.xenahubs.net"
dataset <- "tcga_RSEM_gene_tpm"
samples <- c("TCGA-02-0047-01", "TCGA-02-0055-01", "TCGA-02-2483-01", "TCGA-02-2485-01")
probes <- c("ENSG00000282740.1", "ENSG00000000005.5", "ENSG00000000419.12")
genes <- c("TP53", "RB1", "PIK3CA")
fetch()
# Fetch samples
fetch_dataset_samples(host, dataset, 2)
# Fetch identifiers
tryCatch({
fetch_dataset_identifiers(host, dataset)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
# Fetch expression value by probes
tryCatch({
fetch_dense_values(host, dataset, probes, samples, check = FALSE)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
tryCatch({
fetch_dense_values(host, dataset, probes, samples[1], check = TRUE)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
tryCatch({
fetch_dense_values(host, dataset, probes[1], samples[1], check = TRUE)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
tryCatch({
fetch_dense_values(host, dataset, probes[1], samples[1], check = TRUE)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
tryCatch({
expect_error(fetch_dense_values(host, dataset, probes[1], 33, check = TRUE))
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
tryCatch({
fetch_dense_values(host, dataset, c(probes[1], "xxx"), c(samples[1], "xxx"), check = TRUE)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
# The following two are two time consuming
# fetch_dense_values(host, dataset, probes[1], check = TRUE)
# fetch_dense_values(host, dataset, samples = samples[1], check = TRUE)
# Fetch expression value by gene symbol (if the dataset has probeMap)
tryCatch({
fetch_dense_values(host, dataset, genes, samples, check = TRUE, use_probeMap = TRUE)
}, error = function(e) {
if (grepl("500", e$message)) {
message("Bad network, skipping check")
} else {
stop(e$message)
}
})
# Workflow ----------------------------------------------------------------
expect_warning(XenaFilter(xe))
expect_warning(XenaFilter(xe2, filterCohorts = "TCGA Breast Cancer (BRCA)"))
XenaQueryProbeMap(xe3)
# clean all
rm(list = ls())