pca {CellTrails} | R Documentation

## Principal Component Analysis

### Description

Performs principal component analysis by spectral decomposition of a covariance or correlation matrix

### Usage

    pca(sce, do_scaling = TRUE, design = NULL)

### Arguments

`sce` | `SingleCellExperiment` object
`do_scaling` | FALSE = covariance matrix, TRUE = correlation matrix
`design` | A numeric matrix describing the factors that should be blocked

### Details

The calculation is done by a spectral decomposition of the (scaled) covariance matrix of the trajectory features as defined in the `SingleCellExperiment` object. Features with zero variance get automatically removed. Please note that this methods only uses the set of defined trajectory features in a `SingleCellExperiment` object; spike-in controls are ignored and are not listed as trajectory features.
To account for systematic bias in the expression data (e.g., cell cycle effects), a design matrix can be provided for the learning process. It should list the factors that should be blocked and their values per sample. It is suggested to construct a design matrix with `model.matrix`.

### Value

A `list` object containing the following components:

``components`` | Principal components
``eigenvalues`` | Variance per component
``variance`` | Fraction of variance explained by each component
``loadings`` | Loading score for each feature

### Author(s)

Daniel C. Ellwanger

### See Also

`SingleCellExperiment` `model.matrix`

### Examples

    # Example data
    data(exSCE)

    # Principal component analysis
    res <- pca(exSCE)

    # Find relevant number of principal components
    d <- findSpectrum(res$eigenvalues, frac=20)

    barplot(res$variance[d] * 100, ylab="Variance (%)",
            names.arg=colnames(res$components)[d], las=2)
    plot(res$component, xlab="PC1", ylab="PC2")

[Package CellTrails version 1.12.0 Index]