Extract genes by row and cells by column.

# S4 method for Chromium,ANY,ANY,ANY
[(x, i, j, ..., drop = FALSE)

Arguments

x

object from which to extract element(s) or in which to replace element(s).

i

indices specifying elements to extract or replace. Indices are numeric or character vectors or empty (missing) or NULL. Numeric values are coerced to integer as by as.integer (and hence truncated towards zero). Character vectors will be matched to the names of the object (or for matrices/arrays, the dimnames): see ‘Character indices’ below for further details.

For [-indexing only: i, j, can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. i, j, can also be negative integers, indicating elements/slices to leave out of the selection.

When indexing arrays by [ a single argument i can be a matrix with as many columns as there are dimensions of x; the result is then a vector with elements corresponding to the sets of indices in each row of i.

An index value of NULL is treated as if it were integer(0).

j

indices specifying elements to extract or replace. Indices are numeric or character vectors or empty (missing) or NULL. Numeric values are coerced to integer as by as.integer (and hence truncated towards zero). Character vectors will be matched to the names of the object (or for matrices/arrays, the dimnames): see ‘Character indices’ below for further details.

For [-indexing only: i, j, can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. i, j, can also be negative integers, indicating elements/slices to leave out of the selection.

When indexing arrays by [ a single argument i can be a matrix with as many columns as there are dimensions of x; the result is then a vector with elements corresponding to the sets of indices in each row of i.

An index value of NULL is treated as if it were integer(0).

...

Additional arguments.

drop

For matrices and arrays. If TRUE the result is coerced to the lowest possible dimension (see the examples). This only works for extracting elements, not for the replacement. See drop for further details.

Value

Chromium.

Details

Refer to cell2sample() 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) cells <- head(colnames(pbmc), 100L) head(cells)
#> [1] "AAACCTGCAGGCGATA" "AAAGCAATCTGCCCTA" "AACCATGAGAGTACCG" "AAGGCAGCACCATCCT" #> [5] "ACCAGTATCTCATTCA" "ACGATACAGCCCAGCT"
genes <- head(rownames(pbmc), 100L) head(genes)
#> [1] "ENSG00000002586" "ENSG00000005022" "ENSG00000007312" "ENSG00000008517" #> [5] "ENSG00000008988" "ENSG00000009307"
## Subset by cell identifiers. pbmc[, cells]
#> class: Chromium #> dim: 500 100 #> metadata(18): version pipeline ... originalVersion subset #> assays(1): counts #> rownames(500): ENSG00000002586 ENSG00000005022 ... ENSG00000277734 #> ENSG00000279483 #> rowData names(4): broadClass geneBiotype geneID geneName #> colnames(100): AAACCTGCAGGCGATA AAAGCAATCTGCCCTA ... TTGCGTCAGCTAAACA #> TTGTAGGCACCATCCT #> colData names(7): nUMI nGene ... mitoRatio sampleID #> reducedDimNames(0): #> spikeNames(0):
## Subset by genes. pbmc[genes, ]
#> Releveling factors in rowRanges.
#> class: Chromium #> dim: 100 100 #> metadata(18): version pipeline ... originalVersion subset #> assays(1): counts #> rownames(100): ENSG00000002586 ENSG00000005022 ... ENSG00000108298 #> ENSG00000108518 #> rowData names(4): broadClass geneBiotype geneID geneName #> colnames(100): AAACCTGCAGGCGATA AAAGCAATCTGCCCTA ... TTGCGTCAGCTAAACA #> TTGTAGGCACCATCCT #> colData names(7): nUMI nGene ... mitoRatio sampleID #> reducedDimNames(0): #> spikeNames(0):
## Subset by both genes and cells. pbmc[genes, cells]
#> Releveling factors in rowRanges.
#> class: Chromium #> dim: 100 100 #> metadata(18): version pipeline ... originalVersion subset #> assays(1): counts #> rownames(100): ENSG00000002586 ENSG00000005022 ... ENSG00000108298 #> ENSG00000108518 #> rowData names(4): broadClass geneBiotype geneID geneName #> colnames(100): AAACCTGCAGGCGATA AAAGCAATCTGCCCTA ... TTGCGTCAGCTAAACA #> TTGTAGGCACCATCCT #> colData names(7): nUMI nGene ... mitoRatio sampleID #> reducedDimNames(0): #> spikeNames(0):