eigencorplot {PCAtools} | R Documentation

## eigencorplot

### Description

Correlate principal components to continuous variable metadata and test significancies of these.

### Usage

    eigencorplot(pcaobj,
      components = getComponents(pcaobj, seq_len(10)),
      metavars,
      titleX = '',
      cexTitleX = 1.0,
      rotTitleX = 0,
      colTitleX = 'black',
      fontTitleX = 2,
      titleY = '',
      cexTitleY = 1.0,
      rotTitleY = 0,
      colTitleY = 'black',
      fontTitleY = 2,
      cexLabX = 1.0,
      rotLabX = 0,
      colLabX = 'black',
      fontLabX = 2,
      cexLabY = 1.0,
      rotLabY = 0,
      colLabY = 'black',
      fontLabY = 2,
      posLab = 'bottomleft',
      col = c('blue4', 'blue3', 'blue2', 'blue1', 'white',
        'red1', 'red2', 'red3', 'red4'),
      posColKey = 'right',
      cexLabColKey = 1.0,
      cexCorval = 1.0,
      colCorval = 'black',
      fontCorval = 1,
      scale = TRUE,
      main = '',
      cexMain = 2,
      rotMain = 0,
      colMain = 'black',
      fontMain = 2,
      corFUN = 'pearson',
      corUSE = 'pairwise.complete.obs',
      signifSymbols = c('***', '**', '*', ''),
      signifCutpoints = c(0, 0.001, 0.01, 0.05, 1),
      colFrame = 'white',
      plotRsquared = FALSE,
      returnPlot = TRUE)

### Arguments

`pcaobj` | Object of class 'pca' created by pca(). REQUIRED.
`components` | The principal components to be included in the plot. DEFAULT = getComponents(pcaobj, seq_len(10)). OPTIONAL.
`metavars` | A vector of column names in metadata representing continuos variables. REQUIRED.
`titleX` | X-axis title. DEFAULT = ”. OPTIONAL.
`cexTitleX` | X-axis title cex. DEFAULT = 1.0. OPTIONAL.
`rotTitleX` | X-axis title rotation in degrees. DEFAULT = 0. OPTIONAL.
`colTitleX` | X-axis title colour. DEFAULT = 'black'. OPTIONAL.
`fontTitleX` | X-axis title font style. 1, plain; 2, bold; 3, italic; 4, bold-italic. DEFAULT = 2. OPTIONAL.
`titleY` | Y-axis title. DEFAULT = ”. OPTIONAL.
`cexTitleY` | Y-axis title cex. DEFAULT = 1.0. OPTIONAL.
`rotTitleY` | Y-axis title rotation in degrees. DEFAULT = 0. OPTIONAL.
`colTitleY` | Y-axis title colour. DEFAULT = 'black'. OPTIONAL.
`fontTitleY` | Y-axis title font style. 1, plain; 2, bold; 3, italic; 4, bold-italic. DEFAULT = 2. OPTIONAL.
`cexLabX` | X-axis labels cex. DEFAULT = 1.0. OPTIONAL.
`rotLabX` | X-axis labels rotation in degrees. DEFAULT = 0. OPTIONAL.
`colLabX` | X-axis labels colour. DEFAULT = 'black'. OPTIONAL.
`fontLabX` | X-axis labels font style. 1, plain; 2, bold; 3, italic; 4, bold-italic. DEFAULT = 2. OPTIONAL.
`cexLabY` | Y-axis labels cex. DEFAULT = 1.0. OPTIONAL.
`rotLabY` | Y-axis labels rotation in degrees. DEFAULT = 0. OPTIONAL.
`colLabY` | Y-axis labels colour. DEFAULT = 'black'. OPTIONAL.
`fontLabY` | Y-axis labels font style. 1, plain; 2, bold; 3, italic; 4, bold-italic. DEFAULT = 2. OPTIONAL.
`posLab` | Positioning of the X- and Y-axis labels. 'bottomleft', bottom and left; 'topright', top and right; 'all', bottom / top and left /right; 'none', no labels. DEFAULT = 'bottomleft'. OPTIONAL.
`col` | Colour shade gradient for RColorBrewer. DEFAULT = c('blue4', 'blue3', 'blue2', 'blue1', 'white', 'red1', 'red2', 'red3', 'red4'). OPTIONAL.
`posColKey` | Position of colour key. 'bottom', 'left', 'top', 'right'. DEFAULT = 'right'. OPTIONAL.
`cexLabColKey` | Colour key labels cex. DEFAULT = 1.0. OPTIONAL.
`cexCorval` | Correlation values cex. DEFAULT = 1.0. OPTIONAL.
`colCorval` | Correlation values colour. DEFAULT = 'black'. OPTIONAL.
`fontCorval` | Correlation values font style. 1, plain; 2, bold; 3, italic; 4, bold-italic. DEFAULT = 1. OPTIONAL.
`scale` | Logical, indicating whether or not to scale the colour range to max and min cor values. DEFAULT = TRUE. OPTIONAL.
`main` | Plot title. DEFAULT = ”. OPTIONAL.
`cexMain` | Plot title cex. DEFAULT = 2. OPTIONAL.
`rotMain` | Plot title rotation in degrees. DEFAULT = 0. OPTIONAL.
`colMain` | Plot title colour. DEFAULT = 'black'. OPTIONAL.
`fontMain` | Plot title font style. 1, plain; 2, bold; 3, italic; 4, bold-italic. DEFAULT = 2. OPTIONAL.
`corFUN` | Correlation method: 'pearson', 'spearman', or 'kendall'. DEFAULT = 'pearson'. OPTIONAL.
`corUSE` | Method for handling missing values (see documentation for cor function via ?cor). 'everything', 'all.obs', 'complete.obs', 'na.or.complete', or 'pairwise.complete.obs'. DEFAULT = 'pairwise.complete.obs'. OPTIONAL.
`signifSymbols` | Statistical significance symbols to display beside correlation values. DEFAULT = c('***', '**', '*', ”). OPTIONAL.
`signifCutpoints` | Cut-points for statistical significance. DEFAULT = c(0, 0.001, 0.01, 0.05, 1). OPTIONAL.
`colFrame` | Frame colour. DEFAULT = 'white'. OPTIONAL.
`plotRsquared` | Logical, indicating whether or not to plot R-squared values. DEFAULT = FALSE. OPTIONAL.
`returnPlot` | Logical, indicating whether or not to return the plot object. DEFAULT = TRUE. OPTIONAL.

### Value

A `lattice` object.

### Author(s)

Kevin Blighe <kevin@clinicalbioinformatics.co.uk>

### Examples

      options(scipen=10)
      options(digits=6)

      col <- 20
      row <- 20000
      mat1 <- matrix(
        rexp(col*row, rate = 0.1),
        ncol = col)
      rownames(mat1) <- paste0('gene', 1:nrow(mat1))
      colnames(mat1) <- paste0('sample', 1:ncol(mat1))

      mat2 <- matrix(
        rexp(col*row, rate = 0.1),
        ncol = col)
      rownames(mat2) <- paste0('gene', 1:nrow(mat2))
      colnames(mat2) <- paste0('sample', (ncol(mat1)+1):(ncol(mat1)+ncol(mat2)))

      mat <- cbind(mat1, mat2)

      metadata <- data.frame(row.names = colnames(mat))
      metadata$Group <- rep(NA, ncol(mat))
      metadata$Group[seq(1,40,2)] <- 'A'
      metadata$Group[seq(2,40,2)] <- 'B'
      metadata$CRP <- sample.int(100, size=ncol(mat), replace=TRUE)
      metadata$ESR <- sample.int(100, size=ncol(mat), replace=TRUE)

      p <- pca(mat, metadata = metadata, removeVar = 0.1)

      eigencorplot(p, components = getComponents(p, 1:10),
        metavars = c('ESR', 'CRP'))

[Package PCAtools version 1.2.0 Index]