Skip to content

Commit

Permalink
Fix a test + add additional tests of the scan1snp() changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed Apr 5, 2024
1 parent 69976cf commit 38ad454
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/testthat/test-scan1snps.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,24 @@ test_that("scan1snps works", {
out <- scan1snps(probs, DOex$pmap, DOex$pheno, query_func=queryf, chr=2, start=97.2, end=97.3)
expect_equal(out, expected)

# if probs and map don't conform, should get an error
# if probs and map don't conform, should get a warning
## (one fewer marker in map)
junk_map <- DOex$pmap
junk_map[[1]] <- junk_map[[1]][-1]
expect_warning( scan1snps(probs, junk_map, DOex$pheno, query_func=queryf, chr=2,
start=97.2, end=97.3) )
## (one fewere marker in probs)
junk_probs <- probs
junk_probs[["2"]] <- junk_probs[["2"]][,,-1]
expect_warning( scan1snps(junk_probs, DOex$pmap, DOex$pheno, query_func=queryf, chr=2,
start=97.2, end=97.3) )
## markers out of order gives an error though
junk_map <- DOex$pmap
names(junk_map[["2"]])[1:5] <- names(junk_map[["2"]])[5:1]
expect_error( scan1snps(probs, junk_map, DOex$pheno, query_func=queryf, chr=2,
start=97.2, end=97.3) )


# using a pre-defined table of snps
snpinfo <- queryf(2, 97.2, 97.3)
out2 <- scan1snps(probs, DOex$pmap, DOex$pheno, snpinfo=snpinfo)
Expand Down

0 comments on commit 38ad454

Please sign in to comment.