single-cell-data / TileDB-SOMA

Python and R SOMA APIs using TileDB’s cloud-native format. Ideal for single-cell data at any scale.
https://tiledbsoma.readthedocs.io
MIT License
90 stars 25 forks source link

[r] Fix bug in blockwise iterator #2965

Closed mojaveazure closed 1 month ago

mojaveazure commented 1 month ago

When using the blockwise iterator, I get the following error on the last iteration's read:

Error: Subarray: Cannot add range to dimension 'soma_dim_0'; Range [2638, 2638] is out of domain bounds [0, 2637]

It turns out we were not handling 0-based coordinates correctly. When creating a new blockwise read, we would start at 0L, but then go up to array$shape()[dimension], which is a 1-indexed value. This needed to be corrected to array$shape()[dimension] - 1L

However, this messed up calculating a dimension for the returning matrix; to get around this, if coords$start == 0L, we increase the length of the coords by 1 (eg. if the coordinates run from [0, 499], then the length should be 500, not 499)

Modified SOMA methods:

SC-54350