Utility function that enables quick and easy sample selection.

selectSamples(object, ...)

# S4 method for SummarizedExperiment
selectSamples(object, ...)

# S4 method for SingleCellExperiment
selectSamples(object, ...)

Arguments

object

Object.

...

Selection arguments:

  • Key value pairs that must map to the column names of sampleData().

  • atomic values are supported.

  • Avoid using logical or numeric indices (e.g. which() return), thereby making your code more human readable, and easier to interpret.

Value

Modified object. Subset (extraction) containing the desired samples.

Details

Internally, pattern matching against sample and file names is applied using logical grep matching.

Note

Updated 2019-08-19.

Intended usage

This function is intended to be used for sample extraction from Bioconductor container classes where the column names don't correspond to samples (e.g. SingleCellExperiment).

Bracket-based subsetting

Bracket-based subsetting with [ also works on SingleCellExperiment objects but it's not intuitive. In this case, provide cellular barcode identifiers for columns and gene identifiers for rows.

See also

Examples

data( RangedSummarizedExperiment, SingleCellExperiment, package = "acidtest" ) rse <- RangedSummarizedExperiment sce <- SingleCellExperiment ## SummarizedExperiment ==== object <- rse sample <- sampleNames(object) %>% head(1L) print(sample)
#> sample01 #> "sample01"
subset <- selectSamples(object, sampleName = sample) print(subset)
#> class: RangedSummarizedExperiment #> dim: 500 1 #> metadata(3): version date interestingGroups #> assays(1): counts #> rownames(500): gene001 gene002 ... gene499 gene500 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(1): sample01 #> colData names(1): condition
## SingleCellExperiment ==== object <- sce sample <- sampleNames(object) %>% head(1L) print(sample)
#> sample1 #> "sample1"
subset <- selectSamples(object, sampleName = sample)
#> 1 sample matched: sample1.
#> 49 cells matched.
print(subset)
#> class: SingleCellExperiment #> dim: 500 49 #> metadata(2): date selectSamples #> assays(1): counts #> rownames(500): gene001 gene002 ... gene499 gene500 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(49): cell001 cell005 ... cell098 cell099 #> colData names(1): sampleID #> reducedDimNames(0): #> spikeNames(0): #> altExpNames(0):