Useful for quickly checking to see if we have dropped rows or columns containing all zeros.

hasNonZeroRowsAndCols(x, .xname = getNameInParent(x))

## Arguments

x Matrix. Currently requires a matrix or sparseMatrix as input. Not intended to be used directly.

## Value

TRUE on success; FALSE on failure, with cause attribute set.

## Details

This is a common check when handling RNA-seq data prior to generating a heatmap or applying a log transformation, for example.

## Examples

## TRUE ====
x <- matrix(data = seq_len(4), nrow = 2)
print(x)#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4hasNonZeroRowsAndCols(x)#> [1] TRUE
x <- matrix(data = rep(1, times = 2), byrow = TRUE)
print(x)#>      [,1]
#> [1,]    1
#> [2,]    1hasNonZeroRowsAndCols(x)#> [1] TRUE
x <- matrix(data = rep(1, times = 2), byrow = FALSE)
print(x)#>      [,1]
#> [1,]    1
#> [2,]    1hasNonZeroRowsAndCols(x)#> [1] TRUE
## FALSE ====
x <- matrix(nrow = 0, ncol = 0)
print(x)#> <0 x 0 matrix>hasNonZeroRowsAndCols(x)#> [1] FALSE
#> Cause of failure:
#> The number of rows in x is zero.
x <- matrix(nrow = 1, ncol = 0)
print(x)#>
#> [1,]hasNonZeroRowsAndCols(x)#> [1] FALSE
#> Cause of failure:
#> The number of columns in x is zero.
x <- matrix(nrow = 0, ncol = 1)
print(x)#>      [,1]hasNonZeroRowsAndCols(x)#> [1] FALSE
#> Cause of failure:
#> The number of rows in x is zero.