subsetBy {MultiAssayExperiment} | R Documentation

## Subsetting a MultiAssayExperiment object

### Description

A set of functions for extracting and dividing a `MultiAssayExperiment`

### Usage

    subsetByRow(x, y, ...)

    subsetByColData(x, y)

    subsetByColumn(x, y)

    subsetByAssay(x, y)

    ## S4 method for signature 'ExperimentList,ANY'
    subsetByRow(x, y, ...)

    ## S4 method for signature 'ExperimentList,list'
    subsetByRow(x, y)

    ## S4 method for signature 'ExperimentList,List'
    subsetByRow(x, y)

    ## S4 method for signature 'ExperimentList,logical'
    subsetByRow(x, y)

    ## S4 method for signature 'ExperimentList,list'
    subsetByColumn(x, y)

    ## S4 method for signature 'ExperimentList,List'
    subsetByColumn(x, y)

    ## S4 method for signature 'ExperimentList,logical'
    subsetByColumn(x, y)

    ## S4 method for signature 'ExperimentList'
    subsetByAssay(x, y)

    ## S4 method for signature 'MultiAssayExperiment,ANY'
    subsetByColData(x, y)

    ## S4 method for signature 'MultiAssayExperiment,character'
    subsetByColData(x, y)

    ## S4 method for signature 'MultiAssayExperiment,ANY'
    subsetByRow(x, y, ...)

    ## S4 method for signature 'MultiAssayExperiment,ANY'
    subsetByColumn(x, y)

    ## S4 method for signature 'MultiAssayExperiment'
    subsetByAssay(x, y)

    ## S4 method for signature 'MultiAssayExperiment,ANY,ANY,ANY'
    x[i, j, k, ..., drop = TRUE]

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

    ## S4 replacement method for signature 'MultiAssayExperiment,ANY,ANY'
    x[[i, j, ...]] <- value

### Arguments

`x` | A `MultiAssayExperiment` or `ExperimentList`
`y` | Any argument used for subsetting, can be a `character`, `logical`, `integer`, `list` or `List` vector
`...` | Additional arguments passed on to lower level functions.
`i` | Either a `character`, `integer`, `logical` or `GRanges` object for subsetting by rows
`j` | Either a `character`, `logical`, or `numeric` vector for subsetting by `colData` rows. See details for more information.
`k` | Either a `character`, `logical`, or `numeric` vector for subsetting by assays
`drop` | logical (default TRUE) whether to drop empty assay elements in the `ExperimentList`
`value` | An assay compatible with the MultiAssayExperiment API

### Details

Subsetting a MultiAssayExperiment by the j index can yield a call to either `subsetByColData` or `subsetByColumn`. For vector inputs, the subset will be applied to the `colData` rows. For `List`-type inputs, the List will be applied to each of the elements in the `ExperimentList`. The order of the subsetting elements in the `List` must match that of the `ExperimentList` in the `MultiAssayExperiment`.

- subsetBycolData: Select biological units by vector input types

- subsetByColumn: Select observations by assay or for each assay

- subsetByRow: Select rows by assay or for each assay

- subsetByAssay: Select experiments

### Examples

    ## Load the example MultiAssayExperiment
    example("MultiAssayExperiment")

    ## Using experiment names
    subsetByAssay(myMultiAssayExperiment, "Affy")

    ## Using numeric indices
    subsetByAssay(myMultiAssayExperiment, 1:2)

    ## Using a logical vector
    subsetByAssay(myMultiAssayExperiment, c(TRUE, FALSE, TRUE))

    ## Subset by character vector (Jack)
    subsetByColData(myMultiAssayExperiment, "Jack")

    ## Subset by numeric index of colData rows (Jack and Bob)
    subsetByColData(myMultiAssayExperiment, c(1, 3))

    ## Subset by logical indicator of colData rows (Jack and Jill)
    subsetByColData(myMultiAssayExperiment, c(TRUE, TRUE, FALSE, FALSE))

    subsetByColumn(myMultiAssayExperiment, list(Affy = 1:2,
        Methyl450k = c(3,5,2), RNASeqGene = 2:4, GISTIC = 1))

    subsetWith <- S4Vectors::mendoapply(`[`, colnames(myMultiAssayExperiment),
        MoreArgs = list(1:2))
    subsetByColumn(myMultiAssayExperiment, subsetWith)

    ## Use a GRanges object to subset rows where ranged data present
    egr <- GenomicRanges::GRanges(seqnames = "chr2",
        IRanges::IRanges(start = 11, end = 13), strand = "-")
    subsetByRow(myMultiAssayExperiment, egr)

    ## Use a logical vector (recycling used)
    subsetByRow(myMultiAssayExperiment, c(TRUE, FALSE))

    ## Use a character vector
    subsetByRow(myMultiAssayExperiment, "ENST00000355076")

[Package MultiAssayExperiment version 1.6.0 Index]