tests/testthat/test_run_scones.R

library(martini)

test_that("output is as expected", {
  
  c <- rep(1, 3)
  W <- matrix(c(0,1,0,1,0,1,0,1,0,0,0,1), 3, 3)
  W <- as(W, "sparseMatrix")
  
  selected <- run_scones(c, 1, 2, W)
  
  expect_equal(length(selected), 3)
  expect_equal(class(selected), "numeric")

})

test_that("we recover causal SNPs", {
  
  pCausal <- 20
  pNonCausal <- 100
  
  c <- c(rep(10, pCausal), rep(0,pNonCausal))
  
  W <- diag(1, pCausal + pNonCausal, pCausal + pNonCausal)
  W <- cbind(rbind(0, W[-1,-1]),0) + rbind(cbind(0,W[-1,-1]),0)
  W[1:pCausal, 1:pCausal] <- 1
  diag(W) <- 0
  W <- as(W, "sparseMatrix")
  
  selected <- run_scones(c, 1, 2, W)
  
  expect_equal(sum(selected), pCausal)
  expect_true(all(as.logical(selected[1:pCausal])))
  
})

Try the martini package in your browser

Any scripts or data that you put into this service are public.

martini documentation built on Nov. 8, 2020, 5:39 p.m.