pca_association_plot: Graphical test between principal components and a table of...

pca_association_plotR Documentation

Graphical test between principal components and a table of covariates.

Description

Graphical test between principal components and a table of covariates.

Usage

pca_association_plot(a, b, ...)

## S4 method for signature 'data.frame,matrix'
pca_association_plot(
  a,
  b,
  method = c("irlba", "prcomp"),
  n = 20,
  npcs = min(ncol(a) - 1, nrow(a) - 1, 50),
  center = TRUE,
  scale = TRUE,
  max_iterations = 1e+05,
  vars_keep = NULL,
  vars_ignore = NULL,
  ...
)

## S4 method for signature 'ANY,ANY'
pca_association_plot(a, b, ...)

## S4 method for signature 'data.frame,missing'
pca_association_plot(a, b, ...)

## S4 method for signature 'ANY,data.frame'
pca_association_plot(a, b, ...)

## S4 method for signature 'data.frame,irlba_prcomp'
pca_association_plot(
  a,
  b,
  npcs = ncol(b$x),
  ncovariates = 20,
  vars_keep = NULL,
  vars_ignore = NULL,
  progress_bar = FALSE,
  ...
)

## S4 method for signature 'data.frame,prcomp'
pca_association_plot(
  a,
  b,
  npcs = ncol(b$x),
  ncovariates = 20,
  vars_keep = NULL,
  vars_ignore = NULL,
  progress_bar = FALSE,
  ...
)

Arguments

a

A matrix or data.frame-alike of covariates.

b

A matrix, or the output of prcomp.

...

Passed to specific methods.

method

The method used to calculate PCs. Can be "irlba" for prcomp_irlba for truncated PCA or prcomp for standard PCA.

n

The maximum number of variables to be shown in the PCA plot (the top n are taken based on the minimum association p-value).

npcs

The number of PCs to truncate the results to. For large datasets visualising >50 PCs is unwieldy so setting this to (e.g.) 20 can be very useful.

center, scale

Passed to PCA methods. Should the data be scaled and centered before performing PCA?

max_iterations

Passed to prcomp_irlba.

vars_keep, vars_ignore

Vectors of variables to keep or remove from the plot, regardless of p-value filtering.

progress_bar

Show a progress bar when testing associations? Useful for very large datasets.

Value

The output of plot_grid, a set of plots showing variance explained and associations between the columns of a and the principal components of b.

Examples

mat <- matrix(rnorm(1000), ncol = 10)
pc <- prcomp(mat)
pca_association_plot(mat, pc)
## only the top 5 associations
pca_association_plot(mat, pc, n = 5)

Alanocallaghan/nalar documentation built on Feb. 27, 2023, 3:27 p.m.