extract-odm {ondisc}R Documentation

Pull a submatrix into memory using the [[ operator.

Description

Apply the [[ operator to an ondisc_matrix to pull a submatrix into memory. You can pass logical, character, or numeric vectors to [[; character vectors are assumed to refer to feature IDs (for rows) and cell barcodes (for columns).

Usage

## S4 method for signature 'ondisc_matrix,missing,missing'
x[[i, j]]

## S4 method for signature 'ondisc_matrix,ANY,missing'
x[[i, j]]

## S4 method for signature 'ondisc_matrix,missing,ANY'
x[[i, j]]

## S4 method for signature 'ondisc_matrix,ANY,ANY'
x[[i, j]]

## S4 method for signature 'metadata_ondisc_matrix,ANY,ANY'
x[[i, j]]

## S4 method for signature 'multimodal_ondisc_matrix,ANY,ANY'
x[[i, j]]

Arguments

x

an ondisc_matrix object.

i

a vector (numeric, logical, or character) indicating features to pull into memory.

j

a vector (numeric, logical, or character) indicating cells to pull into memory.

Details

You can apply [[ to ondisc_matrix objects only. You cannot apply [[ to metadata_ondisc_matrix or multimodal_ondisc_matrix objects, because in the latter case the data to be accessed is ambiguous.

You can remember the difference between [ and [[ by thinking about R lists: [ is used to subset a list, and [[ is used to access elements stored inside a list. Similarly, [ is used to subset an ondisc_matrix, and [[ is used to access a submatrix usable within R.

Value

a matrix (as implemented by the Matrix package).

Examples

# NOTE: You must create the HDF5 file "expressions.h5" to run this example.
# Navigate to the help file of "create_ondisc_matrix_from_mtx"
# (via ?create_ondisc_matrix_from_mtx), and execute the code in the first code block.

h5_fp <- paste0(tempdir(), "/expressions.h5")
if (file.exists(h5_fp)) {
odm <- ondisc_matrix(h5_file = h5_fp)
# extract cells 100-110:
x <- odm[[,100:110]]
# extract genes ENSG00000188305, ENSG00000257284, ENSG00000251655:
x <- odm[[c("ENSG00000188305", "ENSG00000257284", "ENSG00000251655"),]]
# extract cells CTTAGGACACTGGCGT-1 and AAAGGATTCACATCAG-1:
x <- odm[[,c("CTTAGGACACTGGCGT-1", "AAAGGATTCACATCAG-1")]]
}

[Package ondisc version 1.0.0 Index]