Extract genes by row and cells by column.
Arguments
- x
Object.
- i
Indices specifying elements to extract or replace. Indices are
numericorcharactervectors, empty (missing), orNULL.For more information:
- j
Indices specifying elements to extract or replace. Indices are
numericorcharactervectors, empty (missing), orNULL.For more information:
- ...
Additional arguments.
- drop
For matrices and arrays. If
TRUEthe result is coerced to the lowest possible dimension (see the examples). This only works for extracting elements, not for the replacement. Seedropfor further details.
Details
Refer to cellToSample() and selectSamples() if sample-level extraction is
desired. Note that sampleId is slotted into colData and defines the
cell-to-sample mappings.
Unfiltered cellular barcode distributions for the entire dataset, including
cells not kept in the matrix will be dropped in favor of the nCount column
of colData().
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
Examples
## bcbioSingleCell ====
data(bcb)
cells <- head(colnames(bcb))
head(cells)
#> [1] "AAACACTA_CTTCGATT" "AAACTACA_CCACATTA" "AACTGCCT_GCAAGGAC"
#> [4] "AAGAAGGT_TCTGTGGT" "AAGCCTTC_TAAATAGG" "AATAAGGA_CCACATTA"
genes <- head(rownames(bcb))
head(genes)
#> [1] "ENSG00000071082" "ENSG00000100316" "ENSG00000106631" "ENSG00000108821"
#> [5] "ENSG00000112306" "ENSG00000115414"
## Subset by cell identifiers.
bcb[, cells]
#> bcbioSingleCell 0.7.0
#> uploadDir: /Users/mike/git/monorepo/r-packages/bcbioSingleCell/inst/extdata/indrops
#> dates(2): 2018-01-01 2023-10-05
#> level: genes
#> sampleMetadataFile: ../inst/extdata/indrops/metadata.csv
#> organism: Homo sapiens
#> ensemblRelease: 90
#> interestingGroups: sampleName
#> filtered: FALSE
#> class: SingleCellExperiment
#> dim: 50 6
#> metadata(27): allSamples bcbioCommandsLog ... yaml subset
#> assays(1): counts
#> rownames(50): ENSG00000071082 ENSG00000100316 ... ENSG00000269028
#> ENSG00000282105
#> rowData names(9): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(6): AAACACTA_CTTCGATT AAACTACA_CCACATTA ... AAGCCTTC_TAAATAGG
#> AATAAGGA_CCACATTA
#> colData names(15): aggregate description ... sampleName sequence
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
## Subset by genes.
bcb[genes, ]
#> bcbioSingleCell 0.7.0
#> uploadDir: /Users/mike/git/monorepo/r-packages/bcbioSingleCell/inst/extdata/indrops
#> dates(2): 2018-01-01 2023-10-05
#> level: genes
#> sampleMetadataFile: ../inst/extdata/indrops/metadata.csv
#> organism: Homo sapiens
#> ensemblRelease: 90
#> interestingGroups: sampleName
#> filtered: FALSE
#> class: SingleCellExperiment
#> dim: 6 100
#> metadata(27): allSamples bcbioCommandsLog ... yaml subset
#> assays(1): counts
#> rownames(6): ENSG00000071082 ENSG00000100316 ... ENSG00000112306
#> ENSG00000115414
#> rowData names(9): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(100): AAACACTA_CTTCGATT AAACTACA_CCACATTA ...
#> TGGGAATT_ATATAGGA TGTTATCA_ACGCAGAG
#> colData names(15): aggregate description ... sampleName sequence
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
## Subset by both genes and cells.
bcb[genes, cells]
#> bcbioSingleCell 0.7.0
#> uploadDir: /Users/mike/git/monorepo/r-packages/bcbioSingleCell/inst/extdata/indrops
#> dates(2): 2018-01-01 2023-10-05
#> level: genes
#> sampleMetadataFile: ../inst/extdata/indrops/metadata.csv
#> organism: Homo sapiens
#> ensemblRelease: 90
#> interestingGroups: sampleName
#> filtered: FALSE
#> class: SingleCellExperiment
#> dim: 6 6
#> metadata(27): allSamples bcbioCommandsLog ... yaml subset
#> assays(1): counts
#> rownames(6): ENSG00000071082 ENSG00000100316 ... ENSG00000112306
#> ENSG00000115414
#> rowData names(9): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(6): AAACACTA_CTTCGATT AAACTACA_CCACATTA ... AAGCCTTC_TAAATAGG
#> AATAAGGA_CCACATTA
#> colData names(15): aggregate description ... sampleName sequence
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):