File: test_snpSummary.R

package info (click to toggle)
r-bioc-variantannotation 1.10.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,172 kB
  • ctags: 109
  • sloc: ansic: 1,088; sh: 4; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (6)
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
test_snpSummary_empty <- function()
{
    cnames <- c("g00", "g01", "g11", "a0Freq", "a1Freq", 
                "HWEzscore", "HWEpvalue")
    ## no genotype
    fl <- system.file("unitTests", "cases", 
              "FORMAT_header_no_SAMPLEs.vcf", 
              package="VariantAnnotation")
    res <- suppressWarnings(snpSummary(readVcf(fl, "hg19")))
    checkTrue(all(dim(res) == c(0L, 7L)))
    checkEquals(names(res), cnames)

    ## structural
    fl <- system.file("extdata", "structural.vcf", 
              package="VariantAnnotation")
    res <- suppressWarnings(snpSummary(readVcf(fl, "hg19")))
    checkTrue(all(dim(res) == c(0L, 7L)))
    checkEquals(names(res), cnames)
}

test_snpSummary_output <- function()
{
    fl <- system.file("extdata", "ex2.vcf", 
              package="VariantAnnotation")
    vcf <- readVcf(fl, "hg19")
    res <- snpSummary(vcf)

    checkTrue(is.integer(res$g00))
    checkTrue(is.integer(res$g01))
    checkTrue(is.integer(res$g11))

    checkEquals(nrow(res), nrow(vcf))
    checkEquals(rownames(res), rownames(vcf))

    checkEquals(as.integer(res[1,c("g00", "g01", "g11")]), c(1L, 1L, 1L))
    checkEquals(as.integer(res[2,c("g00", "g01", "g11")]), c(2L, 1L, 0L))
    checkEquals(round(res[["a0Freq"]], 2), c(0.50, 0.83, NA, NA, NA))
    checkEquals(round(res[["a1Freq"]], 2), c(0.50, 0.17, NA, NA, NA))
}