assays: Named assay getters and setters

Description Available methods Author(s) See Also Examples

Description

These are methods for getting or setting assay(sce, i=X, ...) where sce is a SingleCellExperiment object and X is the name of the method. For example, counts will get or set X="counts". This provides some convenience for users as well as encouraging standardization of assay names across packages.

Available methods

In the following code snippets, x is a SingleCellExperiment object, value is a matrix-like object with the same dimensions as x, and ... are further arguments passed to assay (for the getter) or assay<- (for the setter).

counts(x, ...), counts(x, ...) <- value:

Get or set a matrix of raw count data, e.g., number of reads or transcripts.

normcounts(x, ...), normcounts(x, ...) <- value:

Get or set a matrix of normalized values on the same scale as the original counts. For example, counts divided by cell-specific size factors that are centred at unity.

logcounts(x, ...), logcounts(x, ...) <- value:

Get or set a matrix of log-transformed counts or count-like values. In most cases, this will be defined as log-transformed normcounts, e.g., using log base 2 and a pseudo-count of 1.

cpm(x, ...), cpm(x, ...) <- value:

Get or set a matrix of counts-per-million values. This is the read count for each gene in each cell, divided by the library size of each cell in millions.

tpm(x, ...), tpm(x, ...) <- value:

Get or set a matrix of transcripts-per-million values. This is the number of transcripts for each gene in each cell, divided by the total number of transcripts in that cell (in millions).

weights(x, ...), weights(x, ...) <- value:

Get or set a matrix of weights, e.g., observational weights to be used in differential expression analysis.

Author(s)

Aaron Lun

See Also

assay and assay<-, for the wrapped methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
example(SingleCellExperiment, echo=FALSE) # Using the class example
counts(sce) <- matrix(rnorm(nrow(sce)*ncol(sce)), ncol=ncol(sce))
dim(counts(sce))

# One possible way of computing normalized "counts"
sf <- 2^rnorm(ncol(sce))
sf <- sf/mean(sf)
normcounts(sce) <- t(t(counts(sce))/sf)
dim(normcounts(sce))

# One possible way of computing log-counts
logcounts(sce) <- log2(normcounts(sce)+1)
dim(normcounts(sce))

SingleCellExperiment documentation built on Nov. 8, 2020, 7:51 p.m.