[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ micropan  (version  1.0  ) ](/packages/micropan/versions/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
](/link/panpca?package=micropan&version=1.0) ` . 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 ](/link/plot.Panpca?package=micropan&version=1.0) ` 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
](/link/plotScores?package=micropan&version=1.0) ` and ` [ plotLoadings
](/link/plotLoadings?package=micropan&version=1.0) ` for other informative
graphical displays of a ` Panpca ` object. The ` [ summary.Panpca
](/link/summary.Panpca?package=micropan&version=1.0) ` function will print the
same information as plotted by ` [ plot.Panpca
](/link/plot.Panpca?package=micropan&version=1.0) ` . The ` [ str.Panpca
](/link/str.Panpca?package=micropan&version=1.0) ` function will simply print
the number of genomes in the ` Panpca ` object.

##  See Also

` [ panpca ](/link/panpca?package=micropan&version=1.0) ` , ` [ plotScores
](/link/plotScores?package=micropan&version=1.0) ` , ` [ plotLoadings
](/link/plotLoadings?package=micropan&version=1.0) ` .

##  Examples

[ Run this code
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2Fplot.Panpca&utm_source=r-docs&utm_medium=docs&utm_term=plot.Panpca&utm_content=run_example_in_datalab)

    
    
    # 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
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2Fplot.Panpca&utm_source=r-docs&utm_medium=docs&utm_term=plot.Panpca&utm_content=run_example_in