pca: pca: A principal component analysis function

Description Usage Arguments Value Examples

View source: R/pca.R

Description

This is a flexible PCA function that can be run on a standard data frame. It is a wrapper for prcomp/ggplot2 code and can be customised with different colours and font sizes and more.

Usage

1
2
3
4
5
6
7
pca(mydata, printres = FALSE, labels = FALSE, text = FALSE,
  axistextsize = 18, legendtextsize = 18, dotsize = 5,
  textlabelsize = 4, legendtitle = "Group", controlscale = FALSE,
  scale = 1, low = "grey", high = "red", colvec = c("skyblue",
  "gold", "violet", "darkorchid", "slateblue", "forestgreen", "violetred",
  "orange", "midnightblue", "grey31", "black"), printheight = 20,
  printwidth = 22, pcx = 1, pcy = 2, scaler = FALSE)

Arguments

mydata

Data frame or matrix: if dataframe/matrix should have samples as columns and rows as features

printres

Logical flag: whether to print the PCA into current directory

labels

Character vector: if we want to just label with gender for example

text

Character vector: if we wanted to label the samples with text IDs to look for outliers

axistextsize

Numerical value: axis text size

legendtextsize

Numerical value: legend text size

dotsize

Numerical value: dot size

textlabelsize

Numerical value: text inside plot label size

legendtitle

Character vector: text legend title

controlscale

Logical flag: whether to control the colour scale

scale

Numerical value: 1=spectral palette, 2=manual low and high palette, 3=categorical labels

low

Character vector: continuous scale low colour

high

Character vector: continuous scale high colour

colvec

Character vector: a series of colours in vector for categorical labels, e.g. c("sky blue", "gold")

printheight

Numerical value: png height (default=20)

printwidth

Numerical value: png width (default=22)

pcx

Numerical value: which PC to plot on X axis (default=1)

pcy

Numerical value: which PC to plot on Y axis (default=2)

scaler

Logical flag: whether to scale the features of the input data (rows) (default=FALSE)

Value

A PCA plot object

Examples

1
PCA <- pca(mydata)

Example output

***PCA wrapper function***
running...
done.

M3C documentation built on Nov. 8, 2020, 6:50 p.m.