This example shows how to perform principal component analysis (PCA) of an ensemble of NMR models. The protein of interest is ubiquitin, and for illustration puposes, we will repeat the calculations for the ensemble of ubiquitin models that were analyzed in [AB09].
PCA object that stores covariance matrix and principal modes that
describe the dominant changes in the dataset will be obtained.
and principal modes (
Mode) can be used as input to functions in
dynamics module for further analysis.
Also, note that this example applies to any PDB file that contains multiple models.
We start by importing everything from the ProDy package:
In : from prody import * In : from pylab import * In : ion()
We parse only Cα atoms using
parsePDB() (note that it is possible to
repeat this calculation for all atoms):
In : ubi = parsePDB('2k39', subset='calpha')
We use residues 1 to 70, as residues 71 to 76 are very mobile and including them skews the results.
In : ubi = ubi.select('resnum < 71').copy()
In : ensemble = Ensemble('Ubiquitin NMR ensemble') In : ensemble.setCoords( ubi.getCoords() )
Then, we add all of the coordinate sets to the ensemble, and perform an iterative superposition:
In : ensemble.addCoordset( ubi.getCoordsets() ) In : ensemble.iterpose()
PCA is only three lines of code:
In : pca = PCA('Ubiquitin') In : pca.buildCovariance(ensemble) In : pca.calcModes() In : repr(pca) Out: '<PCA: Ubiquitin (20 modes; 70 atoms)>'
Principal modes can be calculated faster using singular value decomposition:
In : svd = PCA('Ubiquitin') In : svd.performSVD(ensemble)
For heterogeneous NMR datasets, both methods yields identical results:
In : abs(svd.getEigvals()[:20] - pca.getEigvals()).max() Out: 1.2434497875801753e-14 In : abs(calcOverlap(pca, svd).diagonal()[:20]).min() Out: 0.99999999999999956
Write NMD file¶
In : writeNMD('ubi_pca.nmd', pca[:3], ubi) Out: 'ubi_pca.nmd'
Let’s print fraction of variance for top ranking 4 PCs (listed in Table S3):
In : for mode in pca[:4]: ....: print calcFractVariance(mode).round(3) ....: 0.134 0.094 0.083 0.065
Compare with ANM results¶
We set the active coordinate set to 79, which is the one that is closest
to the mean structure (note that indices start from 0 in Python).
Then, we perform ANM calculations using
calcANM() for the active
In : ubi.setACSIndex(78) In : anm, temp = calcANM(ubi) In : anm.setTitle('Ubiquitin')
We calculate overlaps between ANM and PCA modes (presented in Table 1).
printOverlapTable() function is handy to print a formatted overlap
In : printOverlapTable(pca[:4], anm[:4]) Overlap Table ANM Ubiquitin #1 #2 #3 #4 PCA Ubiquitin #1 -0.19 -0.30 +0.22 -0.62 PCA Ubiquitin #2 +0.09 -0.72 -0.16 +0.16 PCA Ubiquitin #3 +0.31 -0.06 -0.23 0.00 PCA Ubiquitin #4 +0.11 +0.02 +0.16 -0.31