Skip to content

Commit d547858

Browse files
committed
Auto-reformatted some files with Air
1 parent 9104971 commit d547858

File tree

2 files changed

+75
-78
lines changed

2 files changed

+75
-78
lines changed

app.R

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ options("golem.app.prod" = TRUE)
1818
## In this case, I'm using my local files instead of downloading them
1919
## by telling fetch_data(destdir) where my local files are stored at.
2020
if (!exists('spe'))
21-
spe <-
22-
fetch_data('spe', here::here('data-raw/spatialLIBD_files'))
21+
spe <-
22+
fetch_data('spe', here::here('data-raw/spatialLIBD_files'))
2323
if (!exists('sce_layer'))
24-
sce_layer <-
25-
fetch_data('sce_layer', here::here('data-raw/spatialLIBD_files'))
24+
sce_layer <-
25+
fetch_data('sce_layer', here::here('data-raw/spatialLIBD_files'))
2626
if (!exists('modeling_results'))
27-
modeling_results <-
28-
fetch_data('modeling_results', here::here('data-raw/spatialLIBD_files'))
27+
modeling_results <-
28+
fetch_data('modeling_results', here::here('data-raw/spatialLIBD_files'))
2929

3030
modeling_results <- lapply(modeling_results, function(x) {
31-
colnames(x) <- gsub("ayer", "", colnames(x))
32-
return(x)
31+
colnames(x) <- gsub("ayer", "", colnames(x))
32+
return(x)
3333
})
3434

3535
sig_genes <-
36-
sig_genes_extract_all(
37-
n = nrow(sce_layer),
38-
modeling_results,
39-
sce_layer = sce_layer
40-
)
36+
sig_genes_extract_all(
37+
n = nrow(sce_layer),
38+
modeling_results,
39+
sce_layer = sce_layer
40+
)
4141

4242
options(repos = BiocManager::repositories())
4343
spatialLIBD::run_app(
44-
spe = spe,
45-
sce_layer = sce_layer,
46-
modeling_results = modeling_results,
47-
sig_genes = sig_genes,
44+
spe = spe,
45+
sce_layer = sce_layer,
46+
modeling_results = modeling_results,
47+
sig_genes = sig_genes,
4848
) # add parameters here (if any)

tests/testthat/test-vis_gene.R

Lines changed: 58 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,67 @@
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")
53

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+
)
1614

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+
)
2826

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+
)
4038

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+
)
4846

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(
5352
vis_gene(spe, geneid = c("sum_umi", rownames(spe)[1]))
5453
)
55-
)
5654
)
55+
)
5756

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

Comments
 (0)