convertPCsToSCE {batchelor} | R Documentation

## Convert corrected PCs to a SingleCellExperiment

### Description

Convert low-dimensional corrected PCs to a SingleCellExperiment containing corrected expression values. This is a low-level function and most users should not need to call it.

### Usage

    convertPCsToSCE(
      corrected.df,
      pc.info,
      assay.name = "reconstructed",
      dimred.name = "corrected"
    )

### Arguments

`corrected.df` | A DataFrame containing a nested matrix of low-dimensional `corrected` values and a vector of `batch` identities. Typically produced from `reducedMNN`.
`pc.info` | A list containing PCA statistics, in particular a `rotation` matrix. Typically obtained from the `metadata` of the output from `multiBatchPCA`.
`assay.name` | String specifying the name of the assay to use to store the corrected expression values.
`dimred.name` | String containing the name fo the `reducedDims` to store the low-dimensional corrected values. Set to `NULL` to avoid storing these.

### Details

The corrected expression values are obtained by simply taking the crossproduct of the corrected PCs with the rotation matrix. This reverses the original projection to PC space while retaining the effect of the correction. These values are best used for visualization; the low-dimensional corrected coordinates are more efficient for per-cell operations like clustering, while the original uncorrected expression values are safer to interpret for per-gene analyses.

### Value

A SingleCellExperiment containing a LowRankMatrix with the corrected per-gene expression values. The `colData` contains the batch identities, the `rowData` contains the rotation matrix, and the `reducedDims` contains the low-dimensional corrected values (if `dimred.name` is not `NULL`). All additional metadata from `corrected.df` and `pc.info` is stored in `metadata`.

### Author(s)

Aaron Lun

### See Also

`reducedMNN`, to compute `corrected.df`; and `multiBatchPCA`, to compute `pc.info`.

`fastMNN`, which uses this function to obtain low-rank corrected values.

### Examples

    B1 <- matrix(rnorm(10000), nrow=50) # Batch 1
    B2 <- matrix(rnorm(10000), nrow=50) # Batch 2

    # Equivalent to fastMNN().
    cB1 <- cosineNorm(B1)
    cB2 <- cosineNorm(B2)
    pcs <- multiBatchPCA(cB1, cB2)
    mnn.out <- reducedMNN(pcs[[1]], pcs[[2]])

    sce <- convertPCsToSCE(mnn.out, metadata(pcs))
    sce

[Package batchelor version 1.8.1 Index]