Entering edit mode
I found an error occuring when DelayedArray
is 1-dimensional, the grid spacings is greater than 1, and as.sparse
is TRUE
, as shown below.
library("DelayedArray")
# 2D
darr_2D <- DelayedArray(array(runif(3*4), dim=c(3,4)))
# This does work
sink_grid_2D <- colAutoGrid(darr_2D, ncol=1)
for (bid in seq_along(sink_grid_2D)) {
viewport <- sink_grid_2D[[bid]]
block_sparse <- read_block(darr_2D, viewport, as.sparse=TRUE)
block_dense <- read_block(darr_2D, viewport, as.sparse=FALSE)
# calculate something ...
}
# This does work
sink_grid_2D_2 <- colAutoGrid(darr_2D, ncol=2)
for (bid in seq_along(sink_grid_2D_2)) {
viewport <- sink_grid_2D_2[[bid]]
block_sparse <- read_block(darr_2D, viewport, as.sparse=TRUE)
block_dense <- read_block(darr_2D, viewport, as.sparse=FALSE)
# calculate something ...
}
# 1D
darr_1D <- DelayedArray(array(runif(3), dim=c(3)))
# This does work
sink_grid_1D <- RegularArrayGrid(length(darr_1D), spacings=1)
for (bid in seq_along(sink_grid_1D)) {
viewport <- sink_grid_1D[[bid]]
block_sparse <- read_block(darr_1D, viewport, as.sparse=TRUE)
block_dense <- read_block(darr_1D, viewport, as.sparse=FALSE)
# calculate something ...
}
# This doesn't work
sink_grid_1D_2 <- RegularArrayGrid(length(darr_1D), spacings=2)
for (bid in seq_along(sink_grid_1D_2)) {
viewport <- sink_grid_1D_2[[bid]]
block_sparse <- read_block(darr_1D, viewport, as.sparse=TRUE)
block_dense <- read_block(darr_1D, viewport, as.sparse=FALSE)
# calculate something ...
}
# Error in .normarg_nzdata(nzdata, nrow(nzindex)) :
# 'nzdata' must be a vector
sessionInfo( )
# R version 4.1.0 (2021-05-18)
# Platform: x86_64-pc-linux-gnu (64-bit)
# Running under: Ubuntu 20.04.2 LTS
#
# Matrix products: default
# BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
#
# 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=C
# [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
#
# attached base packages:
# [1] parallel stats4 stats graphics grDevices utils datasets
# [8] methods base
#
# other attached packages:
# [1] testthat_3.0.2 einsum_0.1.0 irlba_2.3.3
# [4] DelayedRandomArray_1.1.0 rTensor_1.4.8 BiocSingular_1.9.0
# [7] HDF5Array_1.21.0 rhdf5_2.37.0 DelayedArray_0.19.0
# [10] IRanges_2.27.0 S4Vectors_0.31.0 MatrixGenerics_1.5.0
# [13] matrixStats_0.58.0 BiocGenerics_0.39.0 Matrix_1.3-3
#
# loaded via a namespace (and not attached):
# [1] Rcpp_1.0.6 magrittr_2.0.1 BiocParallel_1.27.0
# [4] lattice_0.20-44 R6_2.5.0 rlang_0.4.11
# [7] ScaledMatrix_1.1.0 tools_4.1.0 grid_4.1.0
# [10] rsvd_1.0.5 dqrng_0.3.0 Rhdf5lib_1.15.0
# [13] rhdf5filters_1.5.0 compiler_4.1.0 beachmat_2.9.0
When I added the fake second dimension as follows, it works though.