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
data(pbmc_v3)
## CellRanger ====
object <- pbmc_v3
cells <- head(colnames(object), 100L)
head(cells)
#> [1] "AAAGGATAGAGGCCAT" "AAAGGATGTGATTAGA" "AACAACCGTGCACATT" "AACAACCTCTAAGAAG"
#> [5] "AACCAACGTAACATCC" "AAGAACACAACGGCCT"
genes <- head(rownames(object), 100L)
head(genes)
#> [1] "CD11b" "CD127" "CD137" "CD14" "CD15" "CD16"
## Subset by cell identifiers.
object[, cells]
#> class: CellRanger
#> dim: 500 100
#> metadata(23): allSamples call ... wd subset
#> assays(1): counts
#> rownames(500): CD11b CD127 ... PD_1 TIGIT
#> rowData names(8): broadClass geneBiotype ... source type
#> colnames(100): AAAGGATAGAGGCCAT AAAGGATGTGATTAGA ... TTCACGCGTACGGCAA
#> TTTGTTGCAAGCGGAT
#> colData names(8): sampleId sampleName ... log10FeaturesPerCount
#> mitoRatio
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
## Subset by genes.
object[genes, ]
#> class: CellRanger
#> dim: 100 100
#> metadata(23): allSamples call ... wd subset
#> assays(1): counts
#> rownames(100): CD11b CD127 ... ENSG00000102317 ENSG00000102879
#> rowData names(8): broadClass geneBiotype ... source type
#> colnames(100): AAAGGATAGAGGCCAT AAAGGATGTGATTAGA ... TTCACGCGTACGGCAA
#> TTTGTTGCAAGCGGAT
#> colData names(8): sampleId sampleName ... log10FeaturesPerCount
#> mitoRatio
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
## Subset by both genes and cells.
object[genes, cells]
#> class: CellRanger
#> dim: 100 100
#> metadata(23): allSamples call ... wd subset
#> assays(1): counts
#> rownames(100): CD11b CD127 ... ENSG00000102317 ENSG00000102879
#> rowData names(8): broadClass geneBiotype ... source type
#> colnames(100): AAAGGATAGAGGCCAT AAAGGATGTGATTAGA ... TTCACGCGTACGGCAA
#> TTTGTTGCAAGCGGAT
#> colData names(8): sampleId sampleName ... log10FeaturesPerCount
#> mitoRatio
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):