computePca {AffiXcan} | R Documentation

## Perform a PCA on a matrix where columns are variables

### Description

Perform a PCA on a matrix where columns are variables

### Usage

    computePca(data, varExplained, scale)

### Arguments

`data` | A matrix containing the TBA values for a certain genomic region; columns are PWMs, rows are individuals IIDs
`varExplained` | An integer between 0 and 100; varExplained=80 means that the principal components selected to fit the models must explain at least 80 percent of variation of TBA values
`scale` | A logical; if scale=FALSE the TBA values will be only centered, not scaled before performing PCA

### Value

A list containing two objects:

eigenvectors: a matrix containing eigenvectors for those principal components selected according to the param varExplained

pcs: a matrix containing the principal components values selected according to the param varExplained

### Examples

    if (interactive()) {
    tbaMatrixMAE <- readRDS(system.file("extdata","training.tba.toydata.rds",
    package="AffiXcan"))

    tbaMatrix <- MultiAssayExperiment::experiments(tbaMatrixMAE)

    tba <- tbaMatrix$ENSG00000256377.1

    pca <- computePca(data=tba, varExplained=80, scale=TRUE)
    }

[Package AffiXcan version 1.2.0 Index]