Package schrodinger :: Package trajectory :: Package prody :: Module pca :: Class PCA
[hide private]
[frames] | no frames]

Class PCA

object --+    
         |    
   nma.NMA --+
             |
            PCA
Known Subclasses:

A class for Principal Component Analysis (PCA) of conformational ensembles. See examples in :ref:`pca`.

Instance Methods [hide private]
 
__init__(self, name='Unknown')
x.__init__(...) initializes x; see help(type(x)) for signature
 
setCovariance(self, covariance)
Set covariance matrix.
 
buildCovariance(self, coordsets, **kwargs)
Build a covariance matrix for *coordsets* using mean coordinates as the reference.
 
calcModes(self, n_modes=20, turbo=True)
Calculate principal (or essential) modes.
 
performSVD(self, coordsets)
Calculate principal modes using singular value decomposition (SVD).
 
addEigenpair(self, eigenvector, eigenvalue=None)
Add eigen *vector* and eigen *value* pair(s) to the instance.
 
setEigens(self, vectors, values=None)
Set eigen *vectors* and eigen *values*.

Inherited from nma.NMA: __getitem__, __iter__, __len__, __repr__, __str__, getArray, getCovariance, getEigvals, getEigvecs, getModel, getTitle, getVariances, is3d, numAtoms, numDOF, numModes, setTitle

Inherited from nma.NMA (private): _getArray, _getMode, _getTrace, _reset

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name='Unknown')
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

buildCovariance(self, coordsets, **kwargs)

 

Build a covariance matrix for *coordsets* using mean coordinates as the reference. *coordsets* argument may be one of the following:

* :class:`.Ensemble` * :class:`numpy.ndarray` with shape ``(n_csets, n_atoms, 3)``

For ensemble and trajectory objects, ``update_coords=True`` argument can be used to set the mean coordinates as the coordinates of the object.

When *coordsets* is a trajectory object, such as :class:`.DCDFile`, covariance will be built by superposing frames onto the reference coordinate set (see :meth:`.Frame.superpose`). If frames are already aligned, use ``aligned=True`` argument to skip this step.

calcModes(self, n_modes=20, turbo=True)

 
Calculate principal (or essential) modes.  This method uses
:func:`scipy.linalg.eigh`, or :func:`numpy.linalg.eigh`, function
to diagonalize the covariance matrix.

:arg n_modes: number of non-zero eigenvalues/vectors to calculate,
    default is 20, for **None** all modes will be calculated
:type n_modes: int

:arg turbo: when available, use a memory intensive but faster way to
    calculate modes, default is **True**
:type turbo: bool

Overrides: nma.NMA.calcModes

performSVD(self, coordsets)

 

Calculate principal modes using singular value decomposition (SVD). *coordsets* argument may be a :class:`.Ensemble`, or :class:`numpy.ndarray` instance. If *coordsets* is a numpy array, its shape must be ``(n_csets, n_atoms, 3)``. Note that coordinate sets must be aligned prior to SVD calculations.

This is a considerably faster way of performing PCA calculations compared to eigenvalue decomposition of covariance matrix, but is an approximate method when heterogeneous datasets are analyzed. Covariance method should be preferred over this one for analysis of ensembles with missing atomic data. See :ref:`pca-xray-calculations` example for comparison of results from SVD and covariance methods.

addEigenpair(self, eigenvector, eigenvalue=None)

 

Add eigen *vector* and eigen *value* pair(s) to the instance. If eigen *value* is omitted, it will be set to 1. Eigenvalues are set as variances.

Overrides: nma.NMA.addEigenpair

setEigens(self, vectors, values=None)

 

Set eigen *vectors* and eigen *values*. If eigen *values* are omitted, they will be set to 1. Eigenvalues are set as variances.

Overrides: nma.NMA.setEigens