biplot: biplot methods for 'pca' family

Description Usage Arguments Details Value Examples

Description

biplot methods for pca family

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## S3 method for class 'pca'
biplot(
  x,
  comp = c(1, 2),
  ind.names = TRUE,
  group = NULL,
  cutoff = 0,
  col.per.group = NULL,
  col = NULL,
  ind.names.size = 3,
  ind.names.col = color.mixo(4),
  ind.names.repel = TRUE,
  pch = 19,
  pch.levels = NULL,
  pch.size = 2,
  var.names = TRUE,
  var.names.col = "grey40",
  var.names.size = 4,
  var.names.angle = FALSE,
  var.arrow.col = "grey40",
  var.arrow.size = 0.5,
  var.arrow.length = 0.2,
  ind.legend.title = NULL,
  vline = FALSE,
  hline = FALSE,
  legend = if (is.null(group)) FALSE else TRUE,
  legend.title = NULL,
  pch.legend.title = NULL,
  ...
)

Arguments

x

A 'pca' object.

comp

integer vector of length two (or three to 3d). The components that will be used on the horizontal and the vertical axis respectively to project the individuals.

ind.names

either a character vector of names for the individuals to be plotted, or FALSE for no names. If TRUE, the row names of the first (or second) data matrix is used as names (see Details).

group

Factor indicating the group membership for each sample.

cutoff

numeric between 0 and 1. Variables with correlations below this cutoff in absolute value are not plotted (see Details).

col.per.group

character (or symbol) color to be used when 'group' is defined. Vector of the same length as the number of groups.

col

character (or symbol) color to be used, possibly vector.

ind.names.size

Numeric, sample name size.

ind.names.col

Character, sample name colour.

ind.names.repel

Logical, whether to repel away label names.

pch

plot character. A character string or a vector of single characters or integers. See points for all alternatives.

pch.levels

If pch is a factor, a named vector providing the point characters to use. See examples.

pch.size

Numeric, sample point character size.

var.names

Logical indicating whether to show variable names. Alternatively, a character.

var.names.col

Character, variable name colour.

var.names.size

Numeric, variable name size.

var.names.angle

Logical, whether to align variable names to arrow directions.

var.arrow.col

Character, variable arrow colour. If 'NULL', no arrows are shown.

var.arrow.size

Numeric, variable arrow head size.

var.arrow.length

Numeric, length of the arrow head in 'cm'.

ind.legend.title

Character, title of the legend.

vline

Logical, whether to draw the vertical neutral line.

hline

Logical, whether to draw the horizontal neutral line.

legend

Logical, whether to show the legend if group != NULL.

legend.title

Character, the legend title if group != NULL.

pch.legend.title

Character, the legend title if pch is a factor.

...

Not currently used.

pch.legend

Character, the legend title if pch is a factor.

Details

biplot unifies the reduced representation of both the observations/samples and variables of a matrix of multivariate data on the same plot. Essentially, in the reduced space the samples are shown as points/names and the contributions of features to each dimension are shown as directed arrows or vectors.

Value

A ggplot object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
data("mtcars")
pca.mtcars <- pca(mtcars, ncomp = 2, scale = TRUE)
# seed for reproducible geom_text_repel
set.seed(42)
biplot(pca.mtcars)
## correlation cutoff to filter features
biplot(pca.mtcars, cutoff = c(0.8))
## tailor threshold for each component
biplot(pca.mtcars, cutoff = c(0.8, 0.6))

## cutomise ggplot in an arbitrary way
biplot(pca.mtcars) + theme_linedraw() + 
    # add vline
    geom_vline(xintercept = 0, col = 'green') +
    # add hline
    geom_hline(yintercept = 0, col = 'green') +
    # customise labs
    labs(x = 'Principal Component 1', y = 'Principal Component 2')

## group samples
biplot(pca.mtcars, group = mtcars$cyl, legend.title = 'Cyl')

## customise variable labels
biplot(pca.mtcars, 
       var.names.col = color.mixo(2),
       var.names.size = 4,
       var.names.angle = TRUE
       )

## no arrows
biplot(pca.mtcars, group = mtcars$cyl, legend.title = 'Cyl', 
       var.arrow.col = NULL, var.names.col = 'black')

## add x=0 and y=0 lines in function
biplot(pca.mtcars, group = mtcars$cyl, legend.title = 'Cyl', 
       var.arrow.col = NULL, var.names.col = 'black', 
       vline = TRUE, hline = TRUE)

## example with spca
spca.mtcars <- spca(mtcars, ncomp = 2, scale = TRUE, keepX = c(8, 6))
biplot(spca.mtcars, var.names.col = 'black', group = mtcars$gear, 
       legend.title = 'Gear')

Example output

Loading required package: MASS
Loading required package: lattice
Loading required package: ggplot2

Loaded mixOmics 6.14.0
Thank you for using mixOmics!
Tutorials: http://mixomics.org
Bookdown vignette: https://mixomicsteam.github.io/Bookdown
Questions, issues: Follow the prompts at http://mixomics.org/contact-us
Cite us:  citation('mixOmics')

mixOmics documentation built on Nov. 8, 2020, 11:12 p.m.