|
a |
|
b/tests/testthat/test-graph.R |
|
|
1 |
test_that("spatial graphs", { |
|
|
2 |
|
|
|
3 |
# get data |
|
|
4 |
data("xenium_data") |
|
|
5 |
|
|
|
6 |
# spatial graphs |
|
|
7 |
xenium_data <- getSpatialNeighbors(xenium_data, method = "delaunay", verbose = FALSE) |
|
|
8 |
graphs <- vrGraph(xenium_data, graph.type = "delaunay") |
|
|
9 |
expect_true(inherits(graphs,"igraph")) |
|
|
10 |
expect_true(length(igraph::E(graphs)) > 0) |
|
|
11 |
}) |
|
|
12 |
|
|
|
13 |
test_that("overwrite graphs", { |
|
|
14 |
|
|
|
15 |
# spatial graphs |
|
|
16 |
data("xenium_data") |
|
|
17 |
xenium_data <- getSpatialNeighbors(xenium_data, method = "delaunay", verbose = FALSE) |
|
|
18 |
graphs <- vrGraph(xenium_data, graph.type = "delaunay") |
|
|
19 |
xenium_data <- getSpatialNeighbors(xenium_data, method = "delaunay", verbose = FALSE) |
|
|
20 |
graphs <- vrGraph(xenium_data, graph.type = "delaunay") |
|
|
21 |
expect_true(inherits(graphs,"igraph")) |
|
|
22 |
expect_true(length(igraph::E(graphs)) > 0) |
|
|
23 |
|
|
|
24 |
# overwrite using subset of metadata groups |
|
|
25 |
data("xenium_data") |
|
|
26 |
xenium_data <- getSpatialNeighbors(xenium_data, method = "delaunay", group.by = "clusters", group.ids = c(1,2,3,4), verbose = FALSE) |
|
|
27 |
graphs <- vrGraph(xenium_data, graph.type = "delaunay") |
|
|
28 |
expect_true(inherits(graphs,"igraph")) |
|
|
29 |
expect_true(length(igraph::E(graphs)) > 0) |
|
|
30 |
xenium_data <- getSpatialNeighbors(xenium_data, method = "delaunay", group.by = "clusters", group.ids = c(3,4,5,6), verbose = FALSE) |
|
|
31 |
graphs <- vrGraph(xenium_data, graph.type = "delaunay") |
|
|
32 |
expect_true(inherits(graphs,"igraph")) |
|
|
33 |
expect_true(length(igraph::E(graphs)) > 0) |
|
|
34 |
}) |