Analysis¶
Synopsis¶
This example is continued from Calculations. The aim of this part is to perform a quantitative comparison of experimental and theoretical data and to print/save the numerical data that were presented in [AB09].
We start by importing everything from the ProDy package and loading data from the previous part. These steps can be skipped if you are continuing in the same iPython session.
In [1]: from prody import *
In [2]: from pylab import *
In [3]: ion()
In [4]: pca = loadModel('p38_xray.pca.npz')
In [5]: anm = loadModel('1p38.anm.npz')
Variance along PCs¶
Of interest is the fraction of variance that is explained by principal components, which are the dominant modes of variability in the dataset. We can print this information to screen for top 3 PCs as follows:
In [6]: for mode in pca[:3]:
...: var = calcFractVariance(mode)*100
...: print('{0:s} % variance = {1:.2f}'.format(mode, var))
...:
Mode 1 from PCA p38 xray % variance = 29.08
Mode 2 from PCA p38 xray % variance = 16.48
Mode 3 from PCA p38 xray % variance = 10.16
These data were included in Table 1 in [AB09].
Collectivity of modes¶
Collectivity of a normal mode ([BR95]) can be obtained using
calcCollectivity()
:
In [7]: for mode in pca[:3]: # Print PCA mode collectivity
...: coll = calcCollectivity(mode)
...: print('{0:s} collectivity = {1:.2f}'.format(mode, coll))
...:
Mode 1 from PCA p38 xray collectivity = 0.50
Mode 2 from PCA p38 xray collectivity = 0.52
Mode 3 from PCA p38 xray collectivity = 0.30
We can also calculate the collectivity of ANM modes:
In [8]: for mode in pca[:3]: # Print PCA mode collectivity
...: coll = calcCollectivity(mode)
...: print('{0:s} collectivity = {1:.2f}'.format(mode, coll))
...:
Mode 1 from PCA p38 xray collectivity = 0.50
Mode 2 from PCA p38 xray collectivity = 0.52
Mode 3 from PCA p38 xray collectivity = 0.30
This shows that top PCA and ANM modes are highly collective.
Save numeric data¶
ANM
and PCA
instances store calculated numeric data.
Their class documentation lists methods that return eigenvalue, eigenvector,
covariance matrix etc. data to the user. Such data can easily be written into
text files for analysis using external software. The function is to use is
writeArray()
:
In [9]: writeArray('p38_PCA_eigvecs.txt', pca.getEigvecs() ) # PCA eigenvectors
Out[9]: 'p38_PCA_eigvecs.txt'
In [10]: writeModes('p38_ANM_modes.txt', anm) # This function is based on writeArray
Out[10]: 'p38_ANM_modes.txt'