Skip to content

Inconsistent dimnames after matrix multiplication with zero-column output #113

@LTLA

Description

@LTLA

When multiplying a DelayedMatrix with a ordinary matrix, the dimnames changes when the output has no columns:

library(DelayedArray)
X <- DelayedArray(matrix(runif(100), 20, 5))
y <- cbind(runif(5), runif(5))
str(X %*% y) # two columns:
## num [1:20, 1:2] 1.78 1.01 1.38 1.33 2 ...

str(X %*% y[,1,drop=FALSE]) # one column:
## num [1:20, 1] 1.78 1.01 1.38 1.33 2 ...

str(X %*% y[,0,drop=FALSE]) # no columns:
## num[1:20, 0 ] 
## - attr(*, "dimnames")=List of 2
##  ..$ : NULL
##  ..$ : NULL

You can see how the dimnames suddenly changes from NULL to list(NULL, NULL). This is causing BiocSingular's tests to break around some equality checks that use DelayedArrays to compute the expected result.

Session information
R Under development (unstable) (2023-11-10 r85507)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /home/luna/Software/R/trunk/lib/libRblas.so 
LAPACK: /home/luna/Software/R/trunk/lib/libRlapack.so;  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] DelayedArray_0.29.7   SparseArray_1.3.4     S4Arrays_1.3.4       
 [4] abind_1.4-5           IRanges_2.37.1        S4Vectors_0.41.3     
 [7] MatrixGenerics_1.15.0 matrixStats_1.2.0     BiocGenerics_0.49.1  
[10] Matrix_1.6-5         

loaded via a namespace (and not attached):
[1] zlibbioc_1.49.0 lattice_0.22-5  XVector_0.43.1  grid_4.4.0     
[5] compiler_4.4.0  tools_4.4.0     crayon_1.5.2   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions