Learn R Programming

micropan (version 1.0)

plot.Panpca: Plotting and printing Panpca objects

Description

Generic functions for plotting and printing the content of a Panpca object.

Usage

"plot"(x, cum=FALSE, col="black", ...) "summary"(object, ...) "str"(object, ...)

Arguments

x
A Panpca object, see below.
object
A Panpca object, see below.
cum
Logical, default is FALSE, indicating if explained variance should be plotted per component or cumulative.
col
Color, default is "black", of interior and border of bars in the barplot.
...
Optional graphical arguments.

Details

A Panpca object contains the results from a principal component analysis (PCA) on a pan-matrix, and is the output from the function panpca. It is a small (S3) extension of a list, and contains the elements Evar, Scores, Loadings, Scale and Weights. The basic idea of a PCA is to find alternative directions in the space spanned by the pan-matrix columns, in order to be able to visualize or in other ways extract the most relevant information in a small number of dimensions. The variable Evar contains the explained variance for each principal component, scaled such that summed over all components it is 1.0. This quantity indicates the importance of each component, larger values of Evar indicates directions (components) with more information. The plot.Panpca function shows the Evar values in a barplot. You can either plot the Evar value of each component separately (cum=FALSE) or the cumulative value (cum=TRUE). This is the basic plot to follow any principal component decomposition, since it tells you how many components you need to capture the bulk of the information in the data. If e.g. component 1, 2 and 3 have Evar values of 0.4, 0.3 and 0.2, respectively, it means these three direction capture 90% (0.4+0.3+0.2=0.9) of all the variation in the data. For some pan-matrices almost all variation can be found in the very few first directions, but more often it is scattered between many. See plotScores and plotLoadings for other informative graphical displays of a Panpca object. The summary.Panpca function will print the same information as plotted by plot.Panpca. The str.Panpca function will simply print the number of genomes in the Panpca object.

See Also

panpca, plotScores, plotLoadings.

Examples

Run this code
# Loading a Panmat object in the micropan package
data(list="Mpneumoniae.blast.panmat",package="micropan")
ppca.blast <- panpca(Mpneumoniae.blast.panmat)
summary(ppca.blast)
plot(ppca.blast,cum=TRUE)
# This reveals that the two first components together explain more than 64% of the variation

Run the code above in your browser using DataLab