Learn R Programming

phytools (version 2.3-0)

phyl.pca: Phylogenetic principal components analysis

Description

This function performs phylogenetic PCA following Revell (2009).

Usage

phyl.pca(tree, Y, method="BM", mode="cov", ...)
# S3 method for phyl.pca
biplot(x, ...)
scores(object, ...)
# S3 method for phyl.pca
scores(object, ...)
as.princomp(x, ...)
as.prcomp(x, ...)

Value

An object of class "phyl.pca" consisting of a list with some or all of the following elements:

Eval

diagonal matrix of eigenvalues.

Evec

matrix with eigenvectors in columns.

S

matrix with scores.

L

matrix with loadings.

lambda

fitted value of \(\lambda\) (method="lambda" only).

logL

log-likelihood for \(\lambda\) model (method="logL" only).

Arguments

tree

phylogeny as an object of class "phylo".

Y

data matrix with traits in columns.

method

method to obtain the correlation structure: can be "BM" or "lambda".

mode

is the mode for the PCA: can be "cov" or "corr".

x

object of class "phyl.pca" for biplot, as.princomp, and as.prcomp methods.

object

object of class "phyl.pca" for scores method.

...

for S3 plotting method biplot.phyl.pca, other arguments to be passed to biplot.

Author

Liam Revell liam.revell@umb.edu, Joan Maspons

Details

If method="lambda" then \(\lambda\) will be optimized on the interval (0,1) using optimize. Optimization method can be set using the option opt which can take values "ML", "REML", or "fixed". If the last of these is selected than the user should also specify a value of \(\lambda\) to use via the argument lambda.

S3 methods (print, summary, and biplot) are modified from code provided by Joan Maspons and are based on the same methods for objects of class "prcomp". Function biplot now permits the argument choices to be supplied, which should be a vector of length two indicated the two PC axes to be plotted.

S3 method scores extracts or computes (for a matrix of newdata) PC scores given an object of class "phyl.pca".

S3 methods as.prcomp and as.princomp convert the object of class "phyl.pca" to objects of class "prcomp" and "princomp", respectively.

References

Revell, L. J. (2009) Size-correction and principal components for interspecific comparative studies. Evolution, 63, 3258-3268.

Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.

See Also

phyl.cca, phyl.resid, prcomp, princomp

Examples

Run this code
## load data from Mahler et al. (2010)
data(anoletree)
data(anole.data)
## run phylogenetic PCA
anole.pca<-phyl.pca(anoletree,anole.data)
print(anole.pca)
## plot results
plot(anole.pca)
biplot(anole.pca)

Run the code above in your browser using DataLab