pcaplot: Principal component plot coloured by factor

Description Usage Arguments Details Value Author(s) Examples

View source: R/pcaplot.R

Description

Plots pairwise plots for three principal components, with symbols coloured by a factor.

Usage

1
pcaplot(pcs, f)

Arguments

pcs

A data frame or matrix with columns called PC1, PC2, and PC3

f

A factor with length matching the rows of pcs

Details

The plot is drawn in 4 panels using split.screen, and therefore works inside gtxpipe's plotting functions (but is incompatible with par(mfrow), layout or other mechanisms).

Two features of the plot are intended to give a more accurate visual impression of the density of different symbol types, in areas where they overlap. First, symbols are plotted using dark but highly transparent colours. Second, symbols that appear with higher frequencies in the plot are deliberately interleaved in the plotting order (so that all symbols of one type are not plotted ‘on top’ of another type), but symbols that appear with lower frequencies are placed towards the end of the plotting order (so tend to be plotted ‘on top’ for maximum visibility).

The legend is plotted with font size scaling to force the labels to fit into the available space.

Value

Returns invisible null.

Author(s)

Toby Johnson Toby.x.Johnson@gsk.com

Examples

1
2
3
4
5
6
7
8
pcaplot(pcs = cbind(PC1 = rnorm(500) + 7*rbinom(500, 1, .3), 
                    PC2 = rnorm(500),
                    PC3 = rnorm(500) + 6*rbinom(500, 1, .4)),
        f = c(rep("Class A", 230), rep("Class B", 200),
              rep("Class C", 25), rep("Class D", 20), 
              rep("Class E", 10), rep("Class F", 5), 
              rep("Class G", 4), rep("Class H", 3), 
              rep("Class J", 2), rep("Class K", 1))) 

tobyjohnson/gtx documentation built on Aug. 30, 2019, 8:07 p.m.