Last data update: 2014.03.03

R: Principal components analysis of an spectral counts matrix.
counts.pcaR Documentation

Principal components analysis of an spectral counts matrix.

Description

A summary and different plots are given as a result of principal components analysis of an spectral counts matrix.

Usage

counts.pca(msnset, facs = NULL, do.plot = TRUE, snms = NULL, wait = TRUE)

Arguments

msnset

A MSnSet with spectral counts in the expression matrix.

do.plot

A logical indicating whether to plot the PCA PC1/PC2 map.

facs

NULL or a data frame with factors. See details below.

snms

Character vector with sample short names to be plotted. If NULL then 'Xnn' is plotted where 'nn' is the column number in the datset.

wait

This function may draw different plots, one by given factor in facs. When in interactive mode the default is to wait for confirmation before proceeding to the next plot. When wait is FALSE and R in interactive mode, instructs not to wait for confirmation.

Details

The spectral counts matrix is decomposed by means of prcomp. If do.plot is TRUE, a plot is generated for each factor showing the PC1/PC2 samples map, with samples colored as per factor level. If facs is NULL then the factors are taken from pData(msnset).

Value

Invisibly returns a list with values:

pca

The return value obtained from prcomp.

pc.vars

The percentage of variability corresponding to each principal component.

Author(s)

Josep Gregori

See Also

MSnSet, prcomp

Examples

data(msms.dataset)
msnset <- pp.msms.data(msms.dataset)
lst <- counts.pca(msnset)
str(lst)
print(lst$pc.vars[,1:4])

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(msmsEDA)
Loading required package: MSnbase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: mzR
Loading required package: Rcpp
Loading required package: BiocParallel
Loading required package: ProtGenerics

This is MSnbase version 1.20.7 
  Read '?MSnbase' and references therein for information
  about the package and how to get started.


Attaching package: 'MSnbase'

The following object is masked from 'package:stats':

    smooth

The following object is masked from 'package:base':

    trimws

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/msmsEDA/counts.pca.Rd_%03d_medium.png", width=480, height=480)
> ### Name: counts.pca
> ### Title: Principal components analysis of an spectral counts matrix.
> ### Aliases: counts.pca
> ### Keywords: hplot multivariate
> 
> ### ** Examples
> 
> data(msms.dataset)
> msnset <- pp.msms.data(msms.dataset)
> lst <- counts.pca(msnset)
> str(lst)
List of 2
 $ pca    :List of 5
  ..$ sdev    : num [1:14] 163.8 46.1 32.3 22.8 19.3 ...
  ..$ rotation: num [1:675, 1:14] 0.1744 0.2494 -0.0117 0.318 0.7473 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:675] "YJR104C" "YKL060C" "YDR155C" "YGR192C" ...
  .. .. ..$ : chr [1:14] "PC1" "PC2" "PC3" "PC4" ...
  ..$ center  : Named num [1:675] 221 208 173 214 244 ...
  .. ..- attr(*, "names")= chr [1:675] "YJR104C" "YKL060C" "YDR155C" "YGR192C" ...
  ..$ scale   : logi FALSE
  ..$ x       : num [1:14, 1:14] -120.3 -99.9 -127.4 -166 -127.2 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:14] "U2.2502.1" "U2.2502.2" "U2.2502.3" "U2.2502.4" ...
  .. .. ..$ : chr [1:14] "PC1" "PC2" "PC3" "PC4" ...
  ..- attr(*, "class")= chr "prcomp"
 $ pc.vars: num [1:3, 1:14] 163.8201 0.8414 0.8414 46.1183 0.0667 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:3] "Standard deviation" "Proportion of Variance" "Cumulative Proportion"
  .. ..$ : chr [1:14] "PC1" "PC2" "PC3" "PC4" ...
> print(lst$pc.vars[,1:4])
                             PC1      PC2      PC3      PC4
Standard deviation     163.82011 46.11827 32.26952 22.75380
Proportion of Variance   0.84136  0.06668  0.03265  0.01623
Cumulative Proportion    0.84136  0.90804  0.94068  0.95691
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>