tests/testthat/test-mtskat.R

context("Initial multi-threaded SKAT without resampling")

data("small_mtskat_results")
data("small_phenodata")
data("small_covariates")
data("small_pre_allocated_windows_processed")

library(future)

old <- options(stringsAsFactors = FALSE)
options(mc.cores=2)

set.seed(5)

test_that("After pre-allocation, SNP windows are divided in desired n chunks", {
  expect_equal(length(chunk_windows(
    pre_allocated_SNP_windows = small_pre_allocated_windows_processed,
    n_thread = 3)),
    3)
})

test_that("Multi-threaded SKAT produces output matching expected results", {
  expect_equal(mtskat(
    this_phenotype = small_phenodata,
    covariates = small_covariates,
    raw_file_path = small_pre_allocated_windows_processed[[1]][[3]],
    pre_allocated_SNP_windows = small_pre_allocated_windows_processed,
    n_thread = 2),
    small_mtskat_results,
    tolerance = 1e-7) # Due to inequality that appears to be floating point error
})

on.exit(options(old), add = TRUE)
naglemi/mtmcskat documentation built on Aug. 23, 2023, 5:35 p.m.