prep: Pre-process a matrix for PCA

Description Usage Arguments Details Value Author(s) Examples

View source: R/prep.R

Description

Scaling and centering a matrix.

Usage

1
2
prep(object, scale = c("none", "pareto", "vector", "uv"),
  center = TRUE, eps = 1e-12, simple = TRUE, reverse = FALSE, ...)

Arguments

object

Numerical matrix (or an object coercible to such) with samples in rows and variables as columns. Also takes ExpressionSet in which case the transposed expression matrix is used.

scale

One of "UV" (unit variance a=a/σ_{a}) "vector" (vector normalisation b=b/||b||), "pareto" (sqrt UV) or "none" to indicate which scaling should be used to scale the matrix with a variables and b samples. Can also be a vector of scales which should be used to scale the matrix. NULL value is interpreted as "none".

center

Either a logical which indicates if the matrix should be mean centred or not, or a vector with averages which should be suntracted from the matrix. NULL value is interpreted as FALSE

eps

Minimum variance, variable with lower variance are not scaled and warning is issued instead.

simple

Logical indicating if only the data should be returned or a list with the pre-processing statistics as well.

reverse

Logical indicating if matrix should be 'post-processed' instead by multiplying each column with its scale and adding the center. In this case, center and scale should be vectors with the statistics (no warning is issued if not, instead output becomes the same as input).

...

Only used for passing through arguments.

Details

Does basically the same as scale but adds some alternative scaling options and functionality for treating pre-processing as part of a model.

Value

A pre-processed matrix or a list with

center

a vector with the estimated centers

scale

a vector with the estimated scales

data

the pre (or post) processed data

Author(s)

Henning Redestig

Examples

1
2
3
4
5
object <- matrix(rnorm(50), nrow=10)
res <- prep(object, scale="uv", center=TRUE, simple=FALSE)
obj <- prep(object, scale=res$scale, center=res$center)
## same as original
sum((object - prep(obj, scale=res$scale, center=res$center, rev=TRUE))^2)

Example output

Loading required package: Biobase
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, sd, var, xtabs

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

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, 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,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min

Welcome to Bioconductor

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


Attaching package: 'pcaMethods'

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

    loadings

[1] 3.784121e-31

pcaMethods documentation built on Nov. 8, 2020, 6:19 p.m.