Skip to content

Commit

Permalink
[FIX] Deprecated matrix RHS in anatLm to fix #294
Browse files Browse the repository at this point in the history
Still need to clean up dead code related to this feature, but
this solves the issue
  • Loading branch information
cfhammill committed Jun 10, 2021
1 parent abb95a1 commit e8505cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/minc_anatomy.R
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,6 @@ anatLm <- function(formula, data, anat, subset=NULL, weights = NULL) {
matrixName = formula[[2]]
matrixFound = TRUE
data.matrix.left <- t(anat[mf[,"(rowcount)"],])
#data.matrix.left <- vertexTable(filenames)
data.matrix.right <- t(term)
}
}
Expand Down Expand Up @@ -909,7 +908,11 @@ anatLm <- function(formula, data, anat, subset=NULL, weights = NULL) {
rows = append(rows,matrixName)
}


if(matrixFound){
stop("A term in your model is a matrix, this use of `anatLm` is deprecated, "
, "Please merge the two anatomy matrices using rowbind or similar and use a group "
, "add a group indicator to your `data.frame`")
}

# Call subroutine based on whether matrix was found
if(!matrixFound) {
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test_anatLm.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,12 @@ test_that("Weighted anatLm works", {
expect_equivalent(sapply(lmods, AIC), AIC(alm))
})

context("Matrix mode")

test_that("Test that passing a matrix on the RHS fails", {
d <- data.frame(y = rnorm(10))
d$x <- scale(rnorm(10))

expect_error(anatLm(~ x, data = d, anat = as.matrix(d$y)), "matrix")
})

0 comments on commit e8505cd

Please sign in to comment.