|
a |
|
b/tests/testthat/test-voltronobjects.R |
|
|
1 |
test_that("assay", { |
|
|
2 |
|
|
|
3 |
# get data |
|
|
4 |
data("visium_data") |
|
|
5 |
|
|
|
6 |
# get assay names |
|
|
7 |
expect_equal(vrAssayNames(visium_data), "Assay1") |
|
|
8 |
|
|
|
9 |
# get assay object |
|
|
10 |
visium_data[["Assay1"]] |
|
|
11 |
|
|
|
12 |
# subset on assay name |
|
|
13 |
visium_data_sub <- subset(visium_data, assays = "Assay1") |
|
|
14 |
|
|
|
15 |
# subset on assay type |
|
|
16 |
visium_data_sub <- subset(visium_data, assays = "Visium") |
|
|
17 |
|
|
|
18 |
expect_equal(1,1L) |
|
|
19 |
}) |
|
|
20 |
|
|
|
21 |
test_that("sample", { |
|
|
22 |
|
|
|
23 |
# get data |
|
|
24 |
data("visium_data") |
|
|
25 |
|
|
|
26 |
# get sample metadata |
|
|
27 |
SampleMetadata(visium_data) |
|
|
28 |
|
|
|
29 |
# change sample name |
|
|
30 |
visium_data$Sample <- "Test_Sample_Name" |
|
|
31 |
|
|
|
32 |
# check metadata |
|
|
33 |
expect_equal(unique(visium_data$Sample), "Test_Sample_Name") |
|
|
34 |
|
|
|
35 |
# check list name |
|
|
36 |
expect_equal(unique(names(visium_data@samples)), "Test_Sample_Name") |
|
|
37 |
|
|
|
38 |
# check metadata name |
|
|
39 |
sample.metadata <- SampleMetadata(visium_data) |
|
|
40 |
expect_equal(sample.metadata$Sample == "Test_Sample_Name", TRUE) |
|
|
41 |
|
|
|
42 |
expect_equal(1,1L) |
|
|
43 |
}) |
|
|
44 |
|
|
|
45 |
test_that("merge objects", { |
|
|
46 |
|
|
|
47 |
# get data |
|
|
48 |
data("xenium_data") |
|
|
49 |
data("visium_data") |
|
|
50 |
data("melc_data") |
|
|
51 |
|
|
|
52 |
# merge two of same types |
|
|
53 |
xenium_data2 <- xenium_data |
|
|
54 |
xenium_data2$Sample <- "XeniumR2" |
|
|
55 |
merged_data <- merge(xenium_data, xenium_data2, verbose = FALSE) |
|
|
56 |
|
|
|
57 |
# merge two of different types |
|
|
58 |
merged_data <- merge(xenium_data, visium_data, verbose = FALSE) |
|
|
59 |
|
|
|
60 |
# merge multiple |
|
|
61 |
merge_list <- list(xenium_data, visium_data, melc_data) |
|
|
62 |
merged_data <- merge(merge_list[[1]], merge_list[-1], verbose = FALSE) |
|
|
63 |
|
|
|
64 |
expect_equal(1,1L) |
|
|
65 |
}) |
|
|
66 |
|