File: test-fit_to_signatures.R

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

# Get mut_mat
mut_mat <- readRDS(system.file("states/mut_mat_data.rds",
  package = "MutationalPatterns"
))

# Get signatures
signatures <- get_known_signatures()

# Run function
output <- fit_to_signatures(mut_mat, signatures)

# Get expected
expected <- readRDS(system.file("states/snv_refit.rds",
  package = "MutationalPatterns"
))

# Run tests
test_that("Output has correct class", {
  expect_true(inherits(output, "list"))
  expect_true(inherits(output$contribution, "matrix"))
  expect_true(inherits(output$reconstructed, "matrix"))
})

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

# Get indel mut_mat
indel_counts <- readRDS(system.file("states/blood_indel_counts.rds", package = "MutationalPatterns"))

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

# Get expected
expected <- readRDS(system.file("states/indel_refit.rds",
  package = "MutationalPatterns"
))

# Run tests
test_that("Refitting indels gives expected output.", {
  output <- fit_to_signatures(indel_counts, signatures)
  expect_equal(output, expected)
})

# Get dbs mut_mat
dbs_counts <- readRDS(system.file("states/blood_dbs_counts.rds", package = "MutationalPatterns"))

signatures <- get_known_signatures("dbs")


expected <- readRDS(system.file("states/dbs_refit.rds",
  package = "MutationalPatterns"
))

test_that("Refitting dbss gives expected output.", {
  output <- fit_to_signatures(dbs_counts, signatures)
  expect_equal(output, expected)
})