tests/testthat/test.grmCalc.R

# Test for grmCalc


# Exmple 1
# read in the solutions
#snprelate.res <- readRDS("snprelate-example-1.txt")
res1 <- readRDS("eigen-example-1.txt")
res2 <- readRDS("pcaseq-example-1.txt")

# open the test file
test.file <- snpgdsOpen("ex1.gds")
samp.id <- read.gdsn(index.gdsn(test.file, "sample.id"))
snp.id <- read.gdsn(index.gdsn(test.file, "snp.id"))




# These tests are currently "broken". There is a bug in R that causes the test to
# fail when called via R CMD CHECK. However both tests are successful when run at
# the command line.
test_that("grmCalc returns the appropriate GRM matrix and that it is equivalent to SNPRelate",
{
 # expect_equivalent(grmCalc(test.file, c(0.5, 0.5), sampleId = samp.id,
 #                            snpId = snp.id, autosomeOnly = FALSE,
 #                           removeMonosnp = FALSE, maf = NA,
 #                           missingRate = NaN, transpose = FALSE)[[1]],
 #                    res1)

 # expect_equivalent(grmCalc(test.file, c(1, 1), sampleId = samp.id,
 #                            snpId = snp.id, autosomeOnly = FALSE,
 #                           removeMonosnp = FALSE, maf = NaN,
 #                            missingRate = NaN, transpose = FALSE)[[1]],
 #                   res2)
})
snpgdsClose(test.file)
jellily/PCAseq documentation built on May 19, 2019, 4:02 a.m.