|
1 | | -test_that( |
2 | | - "vis_gene", |
3 | | - { |
4 | | - if (!exists("spe")) spe <- fetch_data("spe") |
| 1 | +test_that("vis_gene", { |
| 2 | + if (!exists("spe")) spe <- fetch_data("spe") |
5 | 3 |
|
6 | | - # Non-numeric column to plot |
7 | | - expect_error( |
8 | | - { |
9 | | - p <- vis_gene( |
10 | | - spe, |
11 | | - geneid = c("sum_umi", rownames(spe)[1], "layer_guess") |
12 | | - ) |
13 | | - }, |
14 | | - "'geneid' can not contain non-numeric colData columns\\." |
15 | | - ) |
| 4 | + # Non-numeric column to plot |
| 5 | + expect_error( |
| 6 | + { |
| 7 | + p <- vis_gene( |
| 8 | + spe, |
| 9 | + geneid = c("sum_umi", rownames(spe)[1], "layer_guess") |
| 10 | + ) |
| 11 | + }, |
| 12 | + "'geneid' can not contain non-numeric colData columns\\." |
| 13 | + ) |
16 | 14 |
|
17 | | - # Bad sample ID |
18 | | - expect_error( |
19 | | - { |
20 | | - p <- vis_gene( |
21 | | - spe, |
22 | | - geneid = c("sum_umi", rownames(spe)[1]), |
23 | | - sampleid = "aaa" |
24 | | - ) |
25 | | - }, |
26 | | - "'spe\\$sample_id' must exist and contain the ID aaa" |
27 | | - ) |
| 15 | + # Bad sample ID |
| 16 | + expect_error( |
| 17 | + { |
| 18 | + p <- vis_gene( |
| 19 | + spe, |
| 20 | + geneid = c("sum_umi", rownames(spe)[1]), |
| 21 | + sampleid = "aaa" |
| 22 | + ) |
| 23 | + }, |
| 24 | + "'spe\\$sample_id' must exist and contain the ID aaa" |
| 25 | + ) |
28 | 26 |
|
29 | | - # Bad assayname |
30 | | - expect_error( |
31 | | - { |
32 | | - p <- vis_gene( |
33 | | - spe, |
34 | | - geneid = c("sum_umi", rownames(spe)[1]), |
35 | | - assayname = "aaa" |
36 | | - ) |
37 | | - }, |
38 | | - "'aaa' is not an assay in 'spe'" |
39 | | - ) |
| 27 | + # Bad assayname |
| 28 | + expect_error( |
| 29 | + { |
| 30 | + p <- vis_gene( |
| 31 | + spe, |
| 32 | + geneid = c("sum_umi", rownames(spe)[1]), |
| 33 | + assayname = "aaa" |
| 34 | + ) |
| 35 | + }, |
| 36 | + "'aaa' is not an assay in 'spe'" |
| 37 | + ) |
40 | 38 |
|
41 | | - # Bad geneid |
42 | | - expect_error( |
43 | | - { |
44 | | - p <- vis_gene(spe, geneid = "aaa") |
45 | | - }, |
46 | | - "Could not find the 'geneid'\\(s\\) aaa" |
47 | | - ) |
| 39 | + # Bad geneid |
| 40 | + expect_error( |
| 41 | + { |
| 42 | + p <- vis_gene(spe, geneid = "aaa") |
| 43 | + }, |
| 44 | + "Could not find the 'geneid'\\(s\\) aaa" |
| 45 | + ) |
48 | 46 |
|
49 | | - # Trivially check success with legitimate input |
50 | | - expect_true( |
51 | | - all( |
52 | | - c("gg", "ggplot") %in% class( |
| 47 | + # Trivially check success with legitimate input |
| 48 | + expect_true( |
| 49 | + all( |
| 50 | + c("gg", "ggplot") %in% |
| 51 | + class( |
53 | 52 | vis_gene(spe, geneid = c("sum_umi", rownames(spe)[1])) |
54 | 53 | ) |
55 | | - ) |
56 | 54 | ) |
| 55 | + ) |
57 | 56 |
|
58 | | - |
59 | | - # Bad spatialCoords |
60 | | - spe_temp <- spe |
61 | | - colnames(spatialCoords(spe_temp)) <- c("a", "b") |
62 | | - expect_error( |
63 | | - { |
64 | | - p <- vis_gene(spe_temp, geneid = "sum_umi") |
65 | | - }, |
66 | | - "^Abnormal spatial coordinates" |
67 | | - ) |
68 | | - rm(spe_temp) |
69 | | - } |
70 | | -) |
| 57 | + # Bad spatialCoords |
| 58 | + spe_temp <- spe |
| 59 | + colnames(spatialCoords(spe_temp)) <- c("a", "b") |
| 60 | + expect_error( |
| 61 | + { |
| 62 | + p <- vis_gene(spe_temp, geneid = "sum_umi") |
| 63 | + }, |
| 64 | + "^Abnormal spatial coordinates" |
| 65 | + ) |
| 66 | + rm(spe_temp) |
| 67 | +}) |
0 commit comments