Subset method for a LongTable object.
subset-LongTable-method.Rd
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.table
s stored
in the assays
slot.
This function is endomorphic, it always returns a LongTable object.
Usage
# S4 method for LongTable
subset(x, i, j, assays = assayNames(x), reindex = TRUE)
Arguments
- x
LongTable
The object to subset.- i
character
,numeric
,logical
orcall
Character: pass in a character vector of rownames for theLongTable
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 aLongTable
. Call: Accepts valid query statements to thedata.table
i parameter, this can be used to make complex queries using thedata.table
API for therowData
data.table.- j
character
,numeric
,logical
orcall
Character: pass in a character vector of colnames for theLongTable
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 aLongTable
. Call: Accepts valid query statements to thedata.table
i parameter, this can be used to make complex queries using thedata.table
API for thecolData
data.table.- assays
character
,numeric
orlogical
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 indicatereindex=FALSE
saves ~20% of both execution time and memory allocation. The cost of reindexing decreases the smaller your subset gets.
Examples
# Character
subset(merckLongTable, 'ABT-888', 'CAOV3')
#> <LongTable>
#> dim: 42 2
#> assays(2): sensitivity profiles
#> rownames(42): ABT-888:MK-8776:0.35:0.0925 ABT-888:MK-8776:0.35:0.325 ... Zolinza:ABT-888:0.0925:0.35 Zolinza:ABT-888:0.0925:1.08
#> rowData(5): drug1id drug2id drug1dose drug2dose combination_name
#> colnames(2): CAOV3:1 CAOV3:3
#> colData(2): sampleid batchid
#> metadata(0): none
# Numeric
subset(merckLongTable, 1, c(1, 2))
#> <LongTable>
#> dim: 1 1
#> assays(2): sensitivity profiles
#> rownames(1): 5-FU:Bortezomib:0.35:0.00045
#> rowData(5): drug1id drug2id drug1dose drug2dose combination_name
#> colnames(1): A2058:1
#> colData(2): sampleid batchid
#> metadata(0): none
# Logical
subset(merckLongTable, , colData(merckLongTable)$sampleid == 'A2058')
#> <LongTable>
#> dim: 744 2
#> assays(2): sensitivity profiles
#> rownames(744): 5-FU:Bortezomib:0.35:0.00045 5-FU:Bortezomib:0.35:0.002 ... geldanamycin:Topotecan:0.0223:0.0223 geldanamycin:Topotecan:0.0223:0.0775
#> rowData(5): drug1id drug2id drug1dose drug2dose combination_name
#> colnames(2): A2058:1 A2058:3
#> colData(2): sampleid batchid
#> metadata(0): none
# Call
subset(merckLongTable, drug1id == 'Dasatinib' & drug2id != '5-FU',
sampleid == 'A2058')
#> <LongTable>
#> dim: 8 1
#> assays(2): sensitivity profiles
#> rownames(8): Dasatinib:Dinaciclib:0.024:0.000925 Dasatinib:Dinaciclib:0.024:0.00325 ... Dasatinib:Sorafenib:0.024:10 Dasatinib:Sorafenib:0.024:20
#> rowData(5): drug1id drug2id drug1dose drug2dose combination_name
#> colnames(1): A2058:1
#> colData(2): sampleid batchid
#> metadata(0): none