Skip to content

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

@mattgalbraith

Description

@mattgalbraith

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions