subset-LongTable-method: Subset method for a LongTable object.

subset,LongTable-methodR Documentation

Subset method for a LongTable object.

Description

Allows use of the colData and rowData data.table objects to query based on rowID and colID, which is then used to subset all assay data.tables stored in the assays slot. This function is endomorphic, it always returns a LongTable object.

Usage

## S4 method for signature 'LongTable'
subset(x, i, j, assays = assayNames(x), reindex = TRUE)

Arguments

x

LongTable The object to subset.

i

character, numeric, logical or call Character: pass in a character vector of rownames for the LongTable object or a valid regex query which will be evaluated against the rownames. Numeric or Logical: vector of indices or a logical vector to subset the rows of a LongTable. Call: Accepts valid query statements to the data.table i parameter, this can be used to make complex queries using the data.table API for the rowData data.table.

j

character, numeric, logical or call Character: pass in a character vector of colnames for the LongTable object or a valid regex query which will be evaluated against the colnames. Numeric or Logical: vector of indices or a logical vector to subset the columns of a LongTable. Call: Accepts valid query statements to the data.table i parameter, this can be used to make complex queries using the data.table API for the colData data.table.

assays

character, numeric or logical Optional list of assay names to subset. Can be used to subset the assays list further, returning only the selected items in the new LongTable.

reindex

logical(1) Should index values be reset such that they are the smallest possible set of consecutive integers. Modifies the "rowKey", "colKey", and all assayKey columns. Initial benchmarks indicate reindex=FALSE saves ~20% of both execution time and memory allocation. The cost of reindexing decreases the smaller your subset gets.

Value

LongTable A new LongTable object subset based on the specified parameters.

Examples

# Character
subset(merckLongTable, 'ABT-888', 'CAOV3')
# Numeric
subset(merckLongTable, 1, c(1, 2))
# Logical
subset(merckLongTable, , colData(merckLongTable)$sampleid == 'A2058')
# Call
subset(merckLongTable, drug1id == 'Dasatinib' & drug2id != '5-FU',
    sampleid == 'A2058')


bhklab/CoreGx documentation built on March 14, 2024, 3:04 a.m.