pcaBootPlot: Create 2D PCA Plots with Bootstrapping

Description Usage Arguments Examples

View source: R/pcaBootPlot.R

Description

pcaBootPlot draws a 2D PCA plot using the first 2 principal components using the original and bootstrapped data to give some sense of variability.

Usage

1
2
3
4
5
6
7
8
pcaBootPlot(data = NULL, groups = NULL, min.value = 1,
  all.min.value = FALSE, num.boot.samples = 100, log2.transform = TRUE,
  pdf.filename = NULL, pdf.width = 6, pdf.height = 6,
  draw.legend = FALSE, legend.names = NULL, legend.x = NULL,
  legend.y = NULL, transparency = 77, min.x = NULL, max.x = NULL,
  min.y = NULL, max.y = NULL, correct.inversions = TRUE,
  confidence.regions = FALSE, confidence.size = 0.95, step.size = 0.1,
  trim.proportion = 0, return.samples = FALSE, use.prcomp = FALSE)

Arguments

data

A data.frame where the first column is named "ID" and contains IDs for each item measured. Measurements for each sample are in subsequent columns.

groups

The default value is NULL.

If you want use different colors and shapes to deliniate the samples into groups, you can specify the grouping with this argument. Currently there is a limit of 9 different groups.

For example, if you have three consecutive columns of "untreated" samples followed by three consecutive columns of "treated" samples, you can set this argument to c(1,1,1,2,2,2), and the untreated samples will be red circles and the treated samples will be blue triangles.

min.value

The default value is 1.

This allows you to filter out rows (entries) that will not conribute to the PCA. For example, if you are performing PCA on RNA-seq data, you may wish to filter out genes with less than 1 read per sample, 1 read per group or 1 read overall. If you set all.min.value to TRUE, it will filter entries where at least one sample has less than min.value. If you do not set all.min.value to TRUE, then filtering will be performed by group if groups are specified. In this case, an entry will be filtered out if one or more groups have less than min.value.

If groups are not specified, then only entries where all samples have less than min.value will be removed from the analysis.

groups will also effect filtering based on min.value. See that part of the documentation for details.

all.min.value

This parameter, set to either TRUE or FALSE, affects min.value. See the documentation for min.value for more details.

num.boot.samples

The default value is 100. The number of bootstrap iterations to be performed.

log2.transform

The default value is TRUE. Should the data be log2 transformed or not?

pdf.filename

If you wish to save the the graph as a PDF, you may use this argument to specify the filename.

pdf.width

If you specify a value for pdf.filename, you can specify a width for the saved graph. The default value is 6 inches.

pdf.height

If you specify a value for pdf.filename, you can specify a height for the saved graph. The default value is 6 inches.

draw.legend

The default value is FALSE. Should there be a legend in the graph?

legend.names

If draw.legend is TRUE, you can specify the names of the groups listed in the legend.

legend.x,legend.y

If draw.legend is TRUE, you can specify the x and y axis coordinate for its top left corner.

transparency

The default value is 77. This allow you to set how transparent the bootstrapped symbols are in the graph. Values range from 00 to FF.

min.x,min.y,max.x,max.y

By default, pcaBootPlot automatically determines limits for the x and y axes. Use this option to override this behavior.

correct.inversions

The default value is TRUE. Some of the boostrapped PCAs may have their axes inverted. pcaBootPlot can try to correct for this by ensuring that the PCA loading values are positively correlated with the orginal dataset.

confidence.regions

The default value is FALSE. This option will draw circles that contain confidence.size of the bootstrapped values.

confidence.size

The default value is 0.95. A value betweeo 0 and 1 - the proportion of bootstrapped points that need to be within the confidence regions.

step.size

The default value is 0.1. This option determines how the radii for confidence regions are increased each iteration when trying to contain confidence.size of the bootstrapped samples.

trim.proportion

The default value is 0.0. This is the proportion of entries that should be removed from the plot based on the size of the the confidence regions. This should be a value between 0 and 1. For example, if you set it to 0.1, then the top 10 regions will be removed from the plot.

return.samples

The default value is FALSE. If this is set to TRUE then the program will return the names of the samples that were included in the plot. This can be useful if trim.proportion > 0.

use.prcomp

The default value is FALSE. Usually, pcaBootPlot uses FactoMineR to process samples. However, this can be unnecessarily slow if there are less than 50 samples. By setting use.prcomp to TRUE, it will use prcomp() to process samples and will, most likely, run much faster.

Examples

1
2
3
4
5
6
7
sample1=rnorm(n=100, mean=100, sd=10)
sample2=jitter(sample1, factor=10, amount=10)
sample3=rnorm(n=100, mean=100, sd=10)

data <- data.frame(ID=c(1:100), sample1, sample2, sample3)

pcaBootPlot(data, log2.transform = FALSE)

Example output

Performing PCA on 3 samples

Using FactoMineR for analysis. However you may be able to speed up
  computation by setting use.prcomp to TRUE

There are 0 duplicated entries 
Filtering entries based on min.val and groups...
   100 entries had at least one sample with value > 1 
Using FactoMineR for analysis
Bootstrapping the PCA at the entry level...
Bootstrap iteration: 1 
Bootstrap iteration: 2 
Bootstrap iteration: 3 
Bootstrap iteration: 4 
Bootstrap iteration: 5 
Bootstrap iteration: 6 
Bootstrap iteration: 7 
Bootstrap iteration: 8 
Bootstrap iteration: 9 
Bootstrap iteration: 10 
Bootstrap iteration: 11 
Bootstrap iteration: 12 
Bootstrap iteration: 13 
Bootstrap iteration: 14 
Bootstrap iteration: 15 
Bootstrap iteration: 16 
Bootstrap iteration: 17 
Bootstrap iteration: 18 
Bootstrap iteration: 19 
Bootstrap iteration: 20 
Bootstrap iteration: 21 
Bootstrap iteration: 22 
Bootstrap iteration: 23 
Bootstrap iteration: 24 
Bootstrap iteration: 25 
Bootstrap iteration: 26 
Bootstrap iteration: 27 
Bootstrap iteration: 28 
Bootstrap iteration: 29 
Bootstrap iteration: 30 
Bootstrap iteration: 31 
Bootstrap iteration: 32 
Bootstrap iteration: 33 
Bootstrap iteration: 34 
Bootstrap iteration: 35 
Bootstrap iteration: 36 
Bootstrap iteration: 37 
Bootstrap iteration: 38 
Bootstrap iteration: 39 
Bootstrap iteration: 40 
Bootstrap iteration: 41 
Bootstrap iteration: 42 
Bootstrap iteration: 43 
Bootstrap iteration: 44 
Bootstrap iteration: 45 
Bootstrap iteration: 46 
Bootstrap iteration: 47 
Bootstrap iteration: 48 
Bootstrap iteration: 49 
Bootstrap iteration: 50 
Bootstrap iteration: 51 
Bootstrap iteration: 52 
Bootstrap iteration: 53 
Bootstrap iteration: 54 
Bootstrap iteration: 55 
Bootstrap iteration: 56 
Bootstrap iteration: 57 
Bootstrap iteration: 58 
Bootstrap iteration: 59 
Bootstrap iteration: 60 
Bootstrap iteration: 61 
Bootstrap iteration: 62 
Bootstrap iteration: 63 
Bootstrap iteration: 64 
Bootstrap iteration: 65 
Bootstrap iteration: 66 
Bootstrap iteration: 67 
Bootstrap iteration: 68 
Bootstrap iteration: 69 
Bootstrap iteration: 70 
Bootstrap iteration: 71 
Bootstrap iteration: 72 
Bootstrap iteration: 73 
Bootstrap iteration: 74 
Bootstrap iteration: 75 
Bootstrap iteration: 76 
Bootstrap iteration: 77 
Bootstrap iteration: 78 
Bootstrap iteration: 79 
Bootstrap iteration: 80 
Bootstrap iteration: 81 
Bootstrap iteration: 82 
Bootstrap iteration: 83 
Bootstrap iteration: 84 
Bootstrap iteration: 85 
Bootstrap iteration: 86 
Bootstrap iteration: 87 
Bootstrap iteration: 88 
Bootstrap iteration: 89 
Bootstrap iteration: 90 
Bootstrap iteration: 91 
Bootstrap iteration: 92 
Bootstrap iteration: 93 
Bootstrap iteration: 94 
Bootstrap iteration: 95 
Bootstrap iteration: 96 
Bootstrap iteration: 97 
Bootstrap iteration: 98 
Bootstrap iteration: 99 
Bootstrap iteration: 100 

Done! Hooray!

pcaBootPlot documentation built on May 1, 2019, 10:10 p.m.