read_block_as_sparse: read_block_as_sparse

read_block_as_sparseR Documentation

read_block_as_sparse

Description

read_block_as_sparse() is an internal generic function used by S4Arrays::read_block() when is_sparse(x) is TRUE.

Usage

read_block_as_sparse(x, viewport)

## S4 method for signature 'ANY'
read_block_as_sparse(x, viewport)

Arguments

x

An array-like object for which is_sparse(x) is TRUE.

viewport

An ArrayViewport object compatible with x, that is, such that refdim(viewport) is identical to dim(x).

Details

Like read_block_as_dense() in the S4Arrays package, read_block_as_sparse() is not meant to be called directly by the end user. The end user should always call the higher-level user-facing read_block() function instead. See ?read_block in the S4Arrays package for more information.

Also, like extract_sparse_array(), read_block_as_sparse() should always be called on an array-like object x for which is_sparse(x) is TRUE.

For maximum efficiency, read_block_as_sparse() methods should:

  1. NOT check that is_sparse(x) is TRUE.

  2. NOT try to do anything with the dimnames on x (read_block() takes care of that).

  3. always operate natively on the sparse representation of the data in x, that is, they should never expand it into a dense representation (e.g. with as.array()).

Value

A block of data as a SparseArray derivative (COO_SparseArray or SVT_SparseArray) of the same type() as x.

See Also

  • read_block in the S4Arrays package for the higher-level user-facing function for reading array blocks.

  • ArrayGrid in the S4Arrays package for ArrayGrid and ArrayViewport objects.

  • is_sparse in the S4Arrays package to check whether an object uses a sparse representation of the data or not.

  • SparseArray objects.

  • S4Arrays::type in the S4Arrays package to get the type of the elements of an array-like object.

  • extract_sparse_array for the workhorse behind the default read_block_as_sparse() method.

  • dgCMatrix objects implemented in the Matrix package.


Bioconductor/SparseArray documentation built on Aug. 9, 2024, 6:38 p.m.