50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

OmicKriging (version 1.4.0)

make_PCs_svd: Run Principal Component Analysis (PCA) using base R svd() function.

Description

A simple wrapper around the base R svd() function which returns the top N eigenvectors of a matrix. Use this function to generate covariates for use with the okriging or krigr_cross_validation functions. This wrapper preserves the rownames of the original matrix.

Usage

make_PCs_svd(X, n.top = 2)

Arguments

X
A correlation matrix.
n.top
Number of top principal compenents to return

Value

A matrix of Principal Components of dimension (# of samples) x (n.top). As expected, eigenvectors are ordered by eigenvalue. Rownames are given as sample IDs.

Examples

Run this code
 ## compute PC's using the  gene expression correlation matrix from vignette
 ## load gene expression values from vignette
 expressionFile <- system.file(package = "OmicKriging",
                     "doc/vignette_data/ig_gene_subset.txt.gz")
 ## compute correlation matrix
 geneCorrelationMatrix <- make_GXM(expressionFile)
 ## find top ten PC's of this matrix using SVD
 topPcs <- make_PCs_svd(geneCorrelationMatrix, n.top=10) 

Run the code above in your browser using DataLab