combineLoadings: Combine the loadings/calculate the length of loading vectors

Description Usage Arguments Details Value Examples

View source: R/quantifyViaLoadings.R

Description

The function combineLoadings calculates the length of loading vectors across several principal components within the Cartesian coordinate system.

The length of vectors is calculated along the principal coordinates defined by PC, e.g. if PC = c("PC1", "PC2") the length is calculated along the loadings of principal components 1 and 2.

Usage

1
combineLoadings(loadings, PC = c("PC1", "PC2"))

Arguments

loadings

matrix or data.frame

PC

character

Details

The length of vectors is calculated using the classical way in the cartesian coordinate system.

For 1D (e.g. length of vectors for PC1):

\bar{\bar{a}} = √{a_1^2}

For 2D (e.g. length of vectors for PC1 and PC2):

\bar{\bar{a}} = √{a_1^2 + a_2^2}

For 3D (e.g. length of vectors for PC1, PC2, and PC3):

\bar{\bar{a}} = √{a_1^2 + a_2^2 + a_3^2}

where $a_1$ is the loading of a data point for PC1, $a_2$ for PC2, $a_3$ for PC3, etc.

Value

numeric vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(MatrixQCvis)
library(SummarizedExperiment)
library(tibble)

f <- system.file("protein_datasets/tanzer2020.RDS", 
    package = "apoptosisQuantification")
se <- readRDS(f)
prot <- assay(se)

loadings <- prcomp(t(prot))$rotation |> 
    as.data.frame() |>
    rownames_to_column(var = "feature") |> 
    as_tibble()

apoptosisQuantification:::combineLoadings(loadings = loadings, 
    PC = c("PC1", "PC2")) 

tnaake/apoptosisQuantification documentation built on Feb. 20, 2022, 5:37 p.m.