diff --git a/R/MAPIT.R b/R/MAPIT.R index e7237164..784549e9 100644 --- a/R/MAPIT.R +++ b/R/MAPIT.R @@ -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)) diff --git a/tests/testthat/test-mvmapit-argument-parsing.R b/tests/testthat/test-mvmapit-argument-parsing.R new file mode 100644 index 00000000..b24304cd --- /dev/null +++ b/tests/testthat/test-mvmapit-argument-parsing.R @@ -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) +}) diff --git a/tests/testthat/test-mvmapit-pariwise-executes-without-error.R b/tests/testthat/test-mvmapit-pariwise-executes-without-error.R index dcd3bb66..794883a0 100644 --- a/tests/testthat/test-mvmapit-pariwise-executes-without-error.R +++ b/tests/testthat/test-mvmapit-pariwise-executes-without-error.R @@ -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