schrodinger.trajectory.prody.pca module¶
This module defines classes for principal component analysis (PCA) and essential dynamics analysis (EDA) calculations.
- class schrodinger.trajectory.prody.pca.PCA(name='Unknown')¶
Bases:
schrodinger.trajectory.prody.nma.NMA
A class for Principal Component Analysis (PCA) of conformational ensembles. See examples in :ref:
pca
.- __init__(name='Unknown')¶
- setCovariance(covariance)¶
Set covariance matrix.
- buildCovariance(coordsets, **kwargs)¶
Build a covariance matrix for coordsets using mean coordinates as the reference. coordsets argument may be one of the following:
- class
- 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, usealigned=True
argument to skip this step.
- calcModes(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.- Parameters
n_modes (int) – number of non-zero eigenvalues/vectors to calculate, default is 20, for None all modes will be calculated
turbo (bool) – when available, use a memory intensive but faster way to calculate modes, default is True
- performSVD(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(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.
- setEigens(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.
- __len__()¶
- getArray()¶
Return a copy of eigenvectors array.
- getCovariance()¶
Return covariance matrix. If covariance matrix is not set or yet calculated, it will be calculated using available modes.
- getEigvals()¶
Return eigenvalues. For :class:
PCA
and :class:EDA
models built using coordinate data in Å, unit of eigenvalues is|A2|
. For :class:ANM
, :class:GNM
, and :class:RTB
, on the other hand, eigenvalues are in arbitrary or relative units but they correlate with stiffness of the motion along associated eigenvector.
- getEigvecs()¶
Return a copy of eigenvectors array.
- getModel()¶
Return self.
- getTitle()¶
Return title of the model.
- getTrace()¶
Return trace, and emit a warning message if trace is calculated using eigenvalues of a subset of variances (eigenvalues or inverse eigenvalues).
- getVariances()¶
Return variances. For :class:
PCA
and :class:EDA
models built using coordinate data in Å, unit of variance is|A2|
. For :class:ANM
, :class:GNM
, and :class:RTB
, on the other hand, variance is the inverse of the eigenvalue, so it has arbitrary or relative units.
- is3d()¶
Return True if model is 3-dimensional.
- numAtoms()¶
Return number of atoms.
- numDOF()¶
Return number of degrees of freedom.
- numModes()¶
Return number of modes in the instance (not necessarily maximum number of possible modes).
- setTitle(title)¶
Set title of the model.
- class schrodinger.trajectory.prody.pca.EDA(name='Unknown')¶
Bases:
schrodinger.trajectory.prody.pca.PCA
A class for Essential Dynamics Analysis (EDA) [AA93].
See examples in :ref:
eda
.- AA93
Amadei A, Linssen AB, Berendsen HJ. Essential dynamics of proteins. Proteins 1993 17(4):412-25.
- __init__(name='Unknown')¶
- __len__()¶
- addEigenpair(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.
- buildCovariance(coordsets, **kwargs)¶
Build a covariance matrix for coordsets using mean coordinates as the reference. coordsets argument may be one of the following:
- class
- 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, usealigned=True
argument to skip this step.
- calcModes(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.- Parameters
n_modes (int) – number of non-zero eigenvalues/vectors to calculate, default is 20, for None all modes will be calculated
turbo (bool) – when available, use a memory intensive but faster way to calculate modes, default is True
- getArray()¶
Return a copy of eigenvectors array.
- getCovariance()¶
Return covariance matrix. If covariance matrix is not set or yet calculated, it will be calculated using available modes.
- getEigvals()¶
Return eigenvalues. For :class:
PCA
and :class:EDA
models built using coordinate data in Å, unit of eigenvalues is|A2|
. For :class:ANM
, :class:GNM
, and :class:RTB
, on the other hand, eigenvalues are in arbitrary or relative units but they correlate with stiffness of the motion along associated eigenvector.
- getEigvecs()¶
Return a copy of eigenvectors array.
- getModel()¶
Return self.
- getTitle()¶
Return title of the model.
- getTrace()¶
Return trace, and emit a warning message if trace is calculated using eigenvalues of a subset of variances (eigenvalues or inverse eigenvalues).
- getVariances()¶
Return variances. For :class:
PCA
and :class:EDA
models built using coordinate data in Å, unit of variance is|A2|
. For :class:ANM
, :class:GNM
, and :class:RTB
, on the other hand, variance is the inverse of the eigenvalue, so it has arbitrary or relative units.
- is3d()¶
Return True if model is 3-dimensional.
- numAtoms()¶
Return number of atoms.
- numDOF()¶
Return number of degrees of freedom.
- numModes()¶
Return number of modes in the instance (not necessarily maximum number of possible modes).
- performSVD(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.
- setCovariance(covariance)¶
Set covariance matrix.
- setEigens(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.
- setTitle(title)¶
Set title of the model.