pca_report: Compute an analysis report using principal component analysis...

View source: R/pca_report.R

pca_reportR Documentation

Compute an analysis report using principal component analysis from flashpca tool.

Description

The function can be used in a chunk within a Rmarkdown document/script with results="asis" to render the report.

Usage

pca_report(
  data,
  design,
  id_var = "Sample_ID",
  technical_vars,
  n_comp = 10,
  fig_n_comp = n_comp,
  outliers_threshold = 1.5,
  outliers_quantile = 0.75,
  title_level = 3
)

Arguments

data

A vector or data.frame. The numeric data on which the PCA has to be performed.

design

A data.frame. Additional variables to be used with factorial planes.

id_var

A character. The identifier column used to merge the data.

technical_vars

A vector(character). Variables from design to be used with factorial planes.

n_comp

A numeric. The number of principal components to be computed.

fig_n_comp

A numeric. The number of principal components to be used for figures.

outliers_threshold

A numeric. The threshold to define outliers.

outliers_quantile

A numeric. The upper quantile percentile to use to define outliers, with n x > quantile(x, outliers_quantile) + outliers_threshold * IQR(x).

title_level

A numeric. The markdown title level, i.e., the number of # preceding the section.

Value

A data.frame.

Examples


if (interactive()) {
  pca_report(
    data = t(mtcars),
    design = as.data.table(mtcars, keep.rownames = "Sample_ID"),
    id_var = "Sample_ID",
    technical_vars = c("cyl", "gear", "vs"),
    n_comp = 5,
    fig_n_comp = 5,
    outliers_threshold = 3,
    outliers_quantile = 0.75,
    title_level = 0
  )
}


mcanouil/rain documentation built on Nov. 28, 2022, 10:40 a.m.