File: test-get_mut_type.R

package info (click to toggle)
r-bioc-mutationalpatterns 3.8.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,336 kB
  • sloc: sh: 8; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,661 bytes parent folder | download | duplicates (2)
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
context("test-get_mut_type")

# Get a grl with variants.
grl <- readRDS(system.file("states/blood_grl.rds",
  package = "MutationalPatterns"
))

# Only use two samples to reduce runtime
grl <- grl[1:2]

## Get a specific mutation type.
snv_grl <- get_mut_type(grl, "snv")
indel_grl <- get_mut_type(grl, "indel")
dbs_grl <- get_mut_type(grl, "dbs")
mbs_grl <- get_mut_type(grl, "mbs")
gr_singlesample <- get_mut_type(grl[[1]], type = "dbs")
empty_gr <- get_mut_type(grl[[1]][0], type = "dbs")
gr_nodbs <- get_mut_type(grl[[1]][1:20], type = "dbs")

# Change names of indel_grl, to make them prettier.
remove_names_gr <- function(gr) {
  names(gr) <- seq_along(gr)
  return(gr)
}
indel_grl <- purrr::map(as.list(indel_grl), remove_names_gr) %>%
  GRangesList()

expected_indel_grl <- readRDS(system.file("states/blood_grl_indel.rds",
  package = "MutationalPatterns"
))[1:2]


test_that("Output has correct class", {
  expect_true(inherits(snv_grl, c("GRanges", "CompressedGRangesList")))
  expect_true(inherits(indel_grl, c("GRanges", "CompressedGRangesList")))
  expect_true(inherits(dbs_grl, c("GRanges", "CompressedGRangesList")))
  expect_true(inherits(mbs_grl, c("GRanges", "CompressedGRangesList")))
  expect_true(inherits(gr_singlesample, c("GRanges")))
  expect_true(inherits(empty_gr, c("GRanges")))
  expect_true(inherits(gr_nodbs, c("GRanges")))
})

test_that("Output is equal to expected", {
  expect_equal(indel_grl, expected_indel_grl)
})

test_that("Empty gr is returned when a mut type is not present", {
  expect_equal(length(empty_gr), 0)
})

test_that("Empty gr as input results in a empty output gr", {
  expect_equal(length(gr_nodbs), 0)
})