File: test-get_known_signatures.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 (108 lines) | stat: -rw-r--r-- 3,542 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
context("test-get_known_signatures")

# Get reference snv signature from COSMIC
output <- get_known_signatures()

# Get reference snv signature from COSMIC,
# including potential artifacts.
output_artifact <- get_known_signatures(incl_poss_artifacts = TRUE)

# Get a GRCh38 version of the signatures
output_grch38 = get_known_signatures(genome = "GRCh38")

# Get dbs signatures
output_dbs <- get_known_signatures("dbs")

# Get indel signatures
output_indel <- get_known_signatures("indel")

# Get transcription strand bias snv signatures
output_tsb <- get_known_signatures("tsb_snv")

# Get a GRCh38 version of the signatures
output_v3_1 = get_known_signatures(source = "COSMIC_v3.1")

# Get reference signatures from SIGNAL
output_signal <- get_known_signatures(source = "SIGNAL")

# Get reference signatures from SIGNAL,
# including potential artifacts
output_signal_arti <- get_known_signatures(source = "SIGNAL", incl_poss_artifacts = TRUE)

## Get exposure signatures from SIGNAL
output_exposure <- get_known_signatures(source = "SIGNAL", sig_type = "exposure")

# Get DBS exposure signatures from SIGNAL
output_exposure_dbs <- get_known_signatures("dbs", source = "SIGNAL", sig_type = "exposure")

# Get all tissue specific signatures from SIGNAL
output_tissue <- get_known_signatures(source = "SIGNAL", sig_type = "tissue")


# Get Bladder specific signatures from SIGNAL
output_bladder <- get_known_signatures(
  source = "SIGNAL",
  sig_type = "tissue",
  tissue_type = "Bladder"
)

# Get sparse signatures
output_sparse <- get_known_signatures(source = "SPARSE")


# Perform tests
test_that("Output has correct class", {
  expect_true(inherits(output, "matrix"))
  expect_true(inherits(output_artifact, "matrix"))
  expect_true(inherits(output_grch38, "matrix"))
  expect_true(inherits(output_dbs, "matrix"))
  expect_true(inherits(output_indel, "matrix"))
  expect_true(inherits(output_tsb, "matrix"))
  expect_true(inherits(output_v3_1, "matrix"))
  expect_true(inherits(output_signal, "matrix"))
  expect_true(inherits(output_signal_arti, "matrix"))
  expect_true(inherits(output_exposure, "matrix"))
  expect_true(inherits(output_exposure_dbs, "matrix"))
  expect_true(inherits(output_tissue, "matrix"))
  expect_true(inherits(output_bladder, "matrix"))
  expect_true(inherits(output_sparse, "matrix"))
})

test_that("Output has correct dimensions", {
  expect_equal(dim(output), c(96, 60))
  expect_equal(dim(output_artifact), c(96, 78))
  expect_equal(dim(output_grch38), c(96, 60))
  expect_equal(dim(output_dbs), c(78, 11))
  expect_equal(dim(output_indel), c(83, 18))
  expect_equal(dim(output_tsb), c(192, 65))
  expect_equal(dim(output_v3_1), c(96, 54))
  expect_equal(dim(output_signal), c(96, 29))
  expect_equal(dim(output_signal_arti), c(96, 41))
  expect_equal(dim(output_exposure), c(96, 54))
  expect_equal(dim(output_exposure_dbs), c(78, 8))
  expect_equal(dim(output_tissue), c(96, 192))
  expect_equal(dim(output_bladder), c(96, 7))
  expect_equal(dim(output_sparse), c(96, 10))
})


test_that("An error is thrown when tissue_type is used outside tissue mode.", {
  expect_error(
    {
      get_known_signatures(tissue_type = "Bladder")
    },
    "tissue_type can only be used with `sig_type = 'tissue'`"
  )
})

test_that("An error is thrown when a file doesn't exist.", {
  expect_error(
    {
      get_known_signatures("dbs", source = "SIGNAL")
    },
    paste0(
      "Look at the documentation of \\'get_known_signatures\\(\\)\\' for",
      " all the possible combinations of arguments."
    )
  )
})