0

filter <- apply(expressionMatrix, 2, function (x) (colIQRs(x, na.rm = TRUE) < 1.6))

"Argument x is of class numeric, should be a matrix" error was thrown. How to cope with that? I think logically this code is correct: I remove all columns, whose IQR values is less than 1.6.

How to code this technically?

mercury0114
  • 1,341
  • 2
  • 15
  • 29

1 Answers1

1

colIQRs from package matrixStats requires a matrix as an input. But by wrapping it inside an apply statement, you are giving it only a single column vector at a time. The solution is to send the whole matrix to colIQRs, then subset on the result:

filter <- expressionMatrix[, colIQRs(expressionMatrix, na.rm = TRUE) < 1.6]
dww
  • 30,425
  • 5
  • 68
  • 111