makePCAplot.8: Plot PCA. Version 8.

Description Usage Arguments Details Value

View source: R/makePCAplot.8.R

Description

Plot 2D PCA graph given a data frame. Tailor graphing parameters and save figure in working directory. Also adds percent of variance explained.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
makePCAplot.8(
  df,
  spitOut_PCA_dims = TRUE,
  colorVec,
  label = FALSE,
  label_dist = 0.05,
  main = "PCA",
  cex = 1,
  pch = 16,
  addLegend = FALSE,
  plotOut = FALSE,
  width = 13,
  height = 8,
  plotOutName = "PCA.pdf",
  legendPosition = "topright",
  legendNames = NA,
  legendColors = NA,
  horizontal = NA,
  vertical = NA
)

Arguments

df

A data frame on which PCA plot is based.

colorVec

A vector of colors corresponding to column names of df. Coerced to characted. Defaults to "black" (see http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf).

label

A boolean indicating whether to add labels to PCA dots. Defaults to FALSE.

label_dist

A numeric of the vertical distance between a dot and dot label. Defaults to 0.05.

main

A character of plot title. Defaults to "PCA".

cex

Either a single numeric of label size or a vector of point size. Defaults to a single numeric 1.

pch

A numeric specifying the type of points in the scatter. Defults to 16 which yields filled circles. If many types of points needed please supply a redundant vector of plotting symbol codes (see http://www.statmethods.net/advgraphs/parameters.html) of lenght equal to column names. E.g. pch=c(16,13)[c(rep(1,15),rep(2,125))]

addLegend

A boolean indicating whether to add the legend of colors used in the plot.

plotOut

A boolean indicating whether to save a plot figure in the working directory.

width

A numeric of plot's figure width (applicable only when plotOut==TRUE).

height

A numeric of plot's figure height (applicable only when plotOut==TRUE).

plotOutName

A character of plot figure file name (applicable only when plotOut==TRUE).

legendPosition

A character indicating position of legend. One of "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center. Defults to "topright".

legendNames

A character vector of legend names. Defults to NA.

legendColors

A character vector of colors corresponding to legendNames. Must be in the same left-to-right order (see http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf).

horizontal

A numeric indicating where the draw a horizontal line. Defults to NA.

vertical

A numeric indicating where to draw a vertical line. Defults to NA.

Details

This function, in contrast to previous versions relies on prcomp() function rather than svd() function in computing the eigenvectors.

Value

A PCA plot.


msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.