multi_covar_pca: PCA plots of top two components colored by each covariate

View source: R/multi_covar_pca.R

multi_covar_pcaR Documentation

PCA plots of top two components colored by each covariate

Description

PCA plot of top two principal components using ggplot2 whose shape is defined by group and color in each plot by iterating over each covariate.

Usage

multi_covar_pca(
  object,
  pheno.df,
  name = "covar_pca",
  grp.var = "grp",
  covars = setdiff(colnames(pheno.df), grp.var),
  alpha = 1,
  all.size = NULL,
  facet = NULL,
  rm.leg.title = FALSE,
  labels = FALSE,
  manual.color = NULL,
  manual.shape = NULL,
  plot = TRUE
)

Arguments

object

Matrix-like object with features (e.g. genes) as rows and samples as columns.

pheno.df

Dataframe with rows as samples and columns as phenotypes.

name

Name of file to create. Set to NA to plot to screen instead of to file.

grp.var

Column of pheno.df to include as group variable in PCA plots.

covars

Columns of pheno.df to include as covariates in PCA plots.

alpha

Transparency, passed to geom_point.

all.size

Passed to geom_point size parameter to give size for all points without appearing in legend. ggplot2 default is size=2.

facet

A formula with columns in pheno.df to facet by.

rm.leg.title

Logical indicating if legend title should be removed.

labels

Logical, should sample labels be added next to points?

manual.color

Vector passed to scale_colour_manual for creating a discrete color scale. Vector length should be equal to number of levels in mapped variable.

manual.shape

Vector passed to scale_shape_manual for creating a discrete color scale. Vector length should be equal to number of levels in mapped variable.

plot

Logical; should plot be generated?

Details

PCA is calculated with prcomp.

Value

Invisibly, a list of the first two principal components appended to pheno.df for each covariate.


jdreyf/ezlimmaplot documentation built on Feb. 8, 2025, 2:25 a.m.