tests/testthat/test-examples.R

context("Examples")

data(seqMetaExample)


test_that("basic examples run)", {

  # gaussian case
  cohort1 <- prepScores(Z=Z1, y~sex+bmi, SNPInfo=SNPInfo, data=pheno1)
  cohort2 <- prepScores2(Z=Z1, y~sex+bmi, SNPInfo=SNPInfo, data=pheno1)
  expect_equal(cohort1, cohort2)
  

  cohort1 <- prepScores(Z=Z2, y~sex+bmi, SNPInfo=SNPInfo, kins=kins, data=pheno2)
  cohort2 <- prepScores2(Z=Z2, y~sex+bmi, SNPInfo=SNPInfo, kins=kins, data=pheno2)
  expect_equal(cohort1, cohort2)
  
  
  # binomial case
  cohort1 <- prepScores(Z=Z1, ybin~1, family=binomial(), SNPInfo=SNPInfo, data=pheno1)
  cohort2 <- prepScores2(Z=Z1, ybin~1, family="binomial", SNPInfo=SNPInfo, data=pheno1)  
  expect_equal(cohort1, cohort2)
  
  # survival case
  expect_warning(cohort1 <- prepCox(Z=Z1, Surv(time,status)~strata(sex)+bmi, SNPInfo=SNPInfo, data=pheno1))
  expect_warning(cohort2 <- prepScores2(Z=Z1, Surv(time,status)~strata(sex)+bmi, family="cox", SNPInfo=SNPInfo, data=pheno1))
  expect_equivalent(cohort1, cohort2)
})


si <- SNPInfo

test_that("Verify examples run with non-standard names)", {

  # gaussian case
  cohort1 <- prepScores(Z=Z1, y~sex+bmi, SNPInfo=si, data=pheno1)
  cohort2 <- prepScores2(Z=Z1, y~sex+bmi, SNPInfo=si, data=pheno1)
  expect_equal(cohort1, cohort2)
  
  
  cohort1 <- prepScores(Z=Z2, y~sex+bmi, SNPInfo=si, kins=kins, data=pheno2)
  cohort2 <- prepScores2(Z=Z2, y~sex+bmi, SNPInfo=si, kins=kins, data=pheno2)
  expect_equal(cohort1, cohort2)
  
  
  # binomial case
  cohort1 <- prepScores(Z=Z1, ybin~1, family=binomial(), SNPInfo=si, data=pheno1)
  cohort2 <- prepScores2(Z=Z1, ybin~1, family="binomial", SNPInfo=si, data=pheno1)
  expect_equal(cohort1, cohort2)
  
  # survival case
  expect_warning(cohort1 <- prepCox(Z=Z1, Surv(time,status)~strata(sex)+bmi, SNPInfo=si, data=pheno1))
  expect_warning(cohort2 <- prepScores2(Z=Z1, Surv(time,status)~strata(sex)+bmi, family="cox", SNPInfo=si, data=pheno1))
  expect_equivalent(cohort1, cohort2)
})

Try the seqMeta package in your browser

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

seqMeta documentation built on May 2, 2019, 10:59 a.m.