Utility function that enables quick and easy sample selection.
Arguments
- object
Object.
- ...
Selection arguments:
Key value pairs that must map to the column names of
sampleData()
.atomic
values are supported.Avoid using
logical
ornumeric
indices (e.g.which()
return), thereby making your code more human readable, and easier to interpret.
Details
Internally, pattern matching against sample and file names is applied using logical grep matching.
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.
Examples
data(SingleCellExperiment_splatter, package = "AcidTest")
## SingleCellExperiment ====
object <- SingleCellExperiment_splatter
sample <- Biobase::sampleNames(object)[[1L]]
print(sample)
#> [1] "sample3"
subset <- selectSamples(object, sampleName = sample)
#> ℹ 1 sample matched: "sample3".
#> ℹ 121 cells matched.
print(subset)
#> class: SingleCellExperiment
#> dim: 100 121
#> metadata(2): date selectSamples
#> assays(1): counts
#> rownames(100): gene001 gene002 ... gene099 gene100
#> rowData names(10): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(121): cell001 cell002 ... cell398 cell399
#> colData names(1): sampleId
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):