namedAssays {SingleCellExperiment} | R Documentation

## Named assay fields

### Description

Convenience methods to get or set named assay fields.

### Usage

    ## S4 method for signature 'SingleCellExperiment'
    counts(object, ...)
    ## S4 replacement method for signature 'SingleCellExperiment'
    counts(object, ...) <- value

    ## S4 method for signature 'SingleCellExperiment'
    normcounts(object, ...)
    ## S4 replacement method for signature 'SingleCellExperiment'
    normcounts(object, ...) <- value

    ## S4 method for signature 'SingleCellExperiment'
    logcounts(object, ...)
    ## S4 replacement method for signature 'SingleCellExperiment'
    logcounts(object, ...) <- value

    ## S4 method for signature 'SingleCellExperiment'
    cpm(object, ...)
    ## S4 replacement method for signature 'SingleCellExperiment'
    cpm(object, ...) <- value

    ## S4 method for signature 'SingleCellExperiment'
    tpm(object, ...)
    ## S4 replacement method for signature 'SingleCellExperiment'
    tpm(object, ...) <- value

    ## S4 method for signature 'SingleCellExperiment'
    weights(object, ...)
    ## S4 replacement method for signature 'SingleCellExperiment'
    weights(object, ...) <- value

### Arguments

`object` | A SingleCellExperiment object.
`value` | A numeric matrix of the same dimensions as `object`.
`...` | May contain `withDimnames`, which is forwarded to `assays`

.

### Details

These are wrapper methods for getting or setting `assay(object, i=X, ...)` where `X` is the name of the method. For example, `counts` will get or set `X="counts"`. This provide some convenience for users as well as encouraging standardization of naming across packages.

Our suggested interpretation of the fields are as follows:

`counts`:

  Raw count data, e.g., number of reads or transcripts.

`normcounts`:

  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`:

  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`:

  Counts-per-million. This is the read count for each gene in each cell, divided by the library size of each cell in millions.

`tpm`:

  Transcripts-per-million. 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`:

  A matrix of weights, e.g., observational weights to be used in differential expression analysis.

### Value

Each method returns a matrix from the correspondingly named field in the `assays` slot.

### Author(s)

Aaron Lun

### See Also

`SingleCellExperiment`

### Examples

    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))

[Package SingleCellExperiment version 1.6.0 Index]