Skip to content

Commit

Permalink
MM-32: check if Y is vector and transpose if TRUE (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdstamp authored Jul 16, 2021
1 parent 13d98b9 commit 9e22f15
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
4 changes: 4 additions & 0 deletions R/MAPIT.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ MvMAPIT <- function(X,
log$debug('Logging to file: %s', filePath)
log$addHandler(logging::writeToFile, file=filePath)
}

if (is.vector(Y)) {
Y <- t(Y)
}

log$debug('Running in %s test mode.', test)
log$debug('Genotype matrix: %d x %d', nrow(X), ncol(X))
Expand Down
40 changes: 40 additions & 0 deletions tests/testthat/test-mvmapit-argument-parsing.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
test_that("MvMapit can take a vector as phenotype input. hybrid = FALSE, test = normal", {
# given
p <- 10
n <- 4
pvalues <- matrix(rep(0.48001, 10), ncol = 1)
set.seed(853)
X <- matrix(runif(p * n), ncol = p)
Y <- c(runif(n))
# when
mapit <- MvMAPIT(t(X),
Y,
hybrid = FALSE,
accuracy = 1e-5,
cores = 1,
phenotypeCovariance = 'identity',
logLevel = "ERROR")
# then
expect_equal(mapit$pvalues, pvalues, tolerance = 1e-3)
})

test_that("MvMapit can take a vector as phenotype input. hybrid = FALSE, test = davies", {
# given
p <- 10
n <- 4
pvalues <- matrix(rep(0.209, 10), ncol = 1)
set.seed(853)
X <- matrix(runif(p * n), ncol = p)
Y <- c(runif(n))
# when
mapit <- MvMAPIT(t(X),
Y,
hybrid = FALSE,
test = 'davies',
accuracy = 1e-5,
cores = 1,
phenotypeCovariance = 'identity',
logLevel = "ERROR")
# then
expect_equal(mapit$pvalues, pvalues, tolerance = 1e-3)
})
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ test_that("hybrid = FALSE, C is not NULL, test = 'davies'. phenotypeCovariance =
expect_equal(mapit$pvalues, pvalues, tolerance = 1e-4)
})


test_that("hybrid = FALSE, test = 'davies'. phenotypeCovariance = '', d = 1", {
# given
p <- 10
Expand Down

0 comments on commit 9e22f15

Please sign in to comment.