plot_PCA: plot_PCA: replacement for plot.PCA

View source: R/plot_PCA.R

plot_PCAR Documentation

plot_PCA: replacement for plot.PCA

Description

plot_PCA is a replacement for plot.PCA. Out of this function I took the functionality that I need and added the functionality to emphasize points (variables or individuals). The function plots the variables or individuals information from the structure returned by the function PCA.

Usage

plot_PCA(
  res,
  var_ind = "ind",
  axes = 1:2,
  cex = 1,
  font.std = 1,
  pch.std = 20,
  col.std = "black",
  font.emp = 2,
  pch.emp = pch.std,
  col.emp = "red",
  font.sel = font.std,
  pch.sel = pch.std,
  col.sel = col.std,
  font.sup = 3,
  pch.sup = 1,
  col.sup = "blue",
  show.sup = TRUE,
  select = NULL,
  emphasize = NULL,
  invisible = NULL
)

Arguments

res

Structure that is the output of the function PCA

var_ind

Character string that indicates if variables (var) or individuals (ind) will be plotted. Default: "ind"

axes

Numeric vector with two integers indicating the dimensions that will be plotted. Default: 1:2

cex

Positive number indicating the size of symbols and labels. Default: 1

font.std

Positive integer indicating the font that is used for the standard labels (i.e. not for supplemental, selected or emphasized elements). See description of par() for details: 1 plain text, 2 bold face, 3 italic and 4 bold italic. Default: 1

pch.std

Positive integer indicating the plotting character that is used for the standard points (i.e. not for supplemental, selected or emphasized elements). See description of points for details: 0 open square, 1 open circle, 2 open triangle etc. Default: 20 (i.e. very small closed circle)

col.std

Color specification for the standard elements (i.e. not for supplemental, selected or emphasized elements). See description of par() for details of specification. Default: "black"

font.emp

Positive integer indicating the font that is used for the labels of emphasized elements. See description of font.std. Default: 2

pch.emp

Positive integer indicating the plotting character that is used for the emphasized points. See description of pch.std. Default: pch.std

col.emp

Color specification for emphasized elements. See description of col.std. Default: "red"

font.sel

Positive integer indicating the font that is used for the labels of selected elements. See description of font.std. Default: font.std

pch.sel

Positive integer indicating the plotting character that is used for the selected points. See description of pch.std. Default: pch.std

col.sel

Color specification for selected elements. See description of col.std. Default: col.std

font.sup

Positive integer indicating the font that is used for the labels of supplemental elements. See description of font.std. Default: 3

pch.sup

Positive integer indicating the plotting character that is used for the supplemental points. See description of pch.std. Default: 1

col.sup

Color specification for supplemental elements. See description of col.std. Default: "blue"

show.sup

Boolean indicating if supplemental elements should be shown. Default: TRUE

select

Character string with a selection criterion (see details) or an integer vector with the sequence numbers of the active elements that are selected (i.e. be given a different layout than the other elements). Default: NULL (i.e. all are selected)

emphasize

Character vector with the rownames or an integer vector with the sequence numbers of the active elements that should be emphasized (i.e. be given a different layout than the other elements). Default: NULL (i.e. none are emphasized)

invisible

Character vector with the rownames of the elements (active and supplemental) that are not shown. Default: NULL

Details

The select mechanism is taken over asis from the FactoMineR::PCA function. The labels of selected elements will be plotted.
The authors Francois Husson husson@agrocampus-ouest.fr and Jeremy Mazet describe it as follows:

The select argument can be used in order to select a part of the elements (individuals if you draw the graph of individuals, or variables if you draw the graph of variables) that are drawn. For example, you can use:
select = 1:5 and then the elements 1:5 are drawn.
select = c("name1","name5") and then the elements that have the names name1 and name5 are drawn.
select = "coord 10" and then the 10 elements that have the highest (squared) coordinates on the 2 chosen dimensions are drawn.
select = "contrib 10" and then the 10 elements that have the highest contribution on the 2 dimensions of your plot are drawn.
select = "cos2 5" and then the 5 elements that have the highest cos2 on the 2 dimensions of your plot are drawn.
select = "dist 8" and then the 8 elements that have the highest distance to the center of gravity are drawn.

NB. the following functionality is contained in plot.PCA but not described there:
select = "cos2 0.8" and then the elements for which the sum of the cos2 on the 2 dimensions of your plot is greater than 0.8 are drawn.

Acknowledgements

All ideas come from the creators of the FactoMineR package. This implementation is mine and if you find any errors, these will be mine. In case of errors try using the original plot.PCA.

Examples

## Not run: 
plot_PCA(res,cex=0.8,show.sup = F,emphasize = 'BU03620304',sel='contrib 6')

## End(Not run)

HanOostdijk/HOQCutil documentation built on July 28, 2023, 5:56 p.m.