explVar: Retrieve the explained variance for each principal component...

View source: R/tab_dimensionreduction.R

explVarR Documentation

Retrieve the explained variance for each principal component (PCA) or axis (PCoA)

Description

The function explVar calculates the proportion of explained variance for each principal component (PC, type = "PCA") and axis (type = "PCoA").

Usage

explVar(d, type = c("PCA", "PCoA"))

Arguments

d

prcomp or list from cmdscale

type

character, one of "PCA" or "PCoA"

Details

explVar uses the function prcomp from the stats package to retrieve the explained standard deviation per PC (type = "PCA") and the function cmdscale from the stats package to retrieve the explained variation based on eigenvalues per Axis (type = "PCoA").

Value

numeric vector with the proportion of explained variance for each PC or Axis

Author(s)

Thomas Naake

Examples

x <- matrix(seq_len(100), nrow = 10, ncol = 10, 
    dimnames = list(seq_len(10), paste("sample", seq_len(10))))
set.seed(1)
x <- x + rnorm(100)

## run for PCA
pca <- dimensionReduction(x = x, 
    params = list(center = TRUE, scale = TRUE), type = "PCA")[[2]]
explVar(d = pca, type = "PCA")

## run for PCoA
pcoa <- dimensionReduction(x = x, 
    params = list(method = "euclidean"), type = "PCoA")[[2]]
explVar(d = pcoa, type = "PCoA")


tnaake/MatrixQCvis documentation built on Nov. 4, 2024, 7:42 a.m.