Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with testing for matrix class in estParam() #2

Open
mattgalbraith opened this issue Jan 24, 2023 · 0 comments
Open

Issue with testing for matrix class in estParam() #2

mattgalbraith opened this issue Jan 24, 2023 · 0 comments

Comments

@mattgalbraith
Copy link

PROPER_1.30.0
R version 4.2.1

Running estParam() with a matrix in R > 4 will throw an error due to matrix objects now inheriting from both "matrix" and "array" classes, which breaks code assuming class(matrix_obj)) has length one.
See
https://stackoverflow.com/questions/64660948/issue-with-creating-a-matrix-in-r
https://cran.r-project.org/doc/manuals/r-release/NEWS.html for R 4.0.0 release

lmu0=rnorm(20000,5,2)
lOD0=rnorm(20000,-4,1)
lmu=exp(rnorm(20000*10,lmu0,exp(lOD0)))
X=matrix(rpois(20000*10,lmu),20000,10)
class(X)

image

param=estParam(X)

image

Replacing the test with !inherits(X, c("ExpressionSet", "matrix")) fixes the issue

estParam2 <- function (X, type = 1) 
{
  # if (!class(X) %in% c("ExpressionSet", "matrix")) 
  #   stop("input X should be either an ExpressionSet or a matrix")
  if (!inherits(X, c("ExpressionSet", "matrix")))
    stop("input X should be either an ExpressionSet or a matrix")
  if (!is.matrix(X)) 
    X = exprs(X)
  if (!(type == 1 | type == 2)) 
    stop("type must be either 1 or 2")
  if (type == 1) {
    res = PROPER:::getDisp1(X)
  }
  if (type == 2) {
    require(edgeR)
    res = PROPER:::getDisp2(X)
  }
  res
}

image

Can submit a pull request if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant