Path A - Module 35: Principal Components (PCA) & Axes#
Molecular trajectories generate thousands of coordinates. Understanding which motions are biologically relevant is like finding a needle in a haystack.
In this module, you will learn to use Principal Component Analysis (PCA) to simplify the dynamics of your complex and Principal Axes to orient your systems in space.
import molsysmt as msm
from molsysmt import systems
# Load a trajectory for analysis
villin_traj = systems['chicken villin HP35']['traj_chicken_villin_HP35_solvated.dcd']
villin_topo = systems['chicken villin HP35']['chicken_villin_HP35_solvated.h5msm']
molsys = [villin_topo, villin_traj]
1. Principal Axes of Inertia#
MolSysMT can find the orientation of your molecule. This is useful to center it and align it with the Cartesian axes (X, Y, Z).
# Get the principal axes of the protein
axes, moments = msm.structure.get_principal_axes(
molsys, selection='molecule_type=="protein"', structure_indices=0, weights='masses'
)
print("Principal Axes vectors:")
print(axes)
print("Principal moments:", moments)
2. Dimensionality Reduction with PCA#
PCA identifies the directions (eigenvectors) along which the system fluctuates the most. MolSysMT returns them from largest to smallest eigenvalue, so the first row is PC1. Eigenvectors are dimensionless and eigenvalues have squared-coordinate units.
# Perform PCA on the alpha carbons of the protein
eigenvectors, eigenvalues = msm.structure.principal_component_analysis(molsys, selection='atom_name=="CA"')
print(f"Eigenvector matrix shape: {eigenvectors.shape}")
print(f"Variance explained by PC1: {eigenvalues[0]}")
3. Aligning to Principal Axes#
For long systems like the Alzheimer’s fibril, it is standard practice to align the longitudinal axis with the Z-axis of the box.
# Align the protein so its longest axis points towards Z
target_axes = [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
molsys = msm.structure.align_principal_axes(
molsys, selection='molecule_type=="protein"', axes=target_axes, weights='masses'
)
print("System aligned to principal axes.")
🏆 Path A Challenge: The Motion Detective#
Perform a PCA on the full Villin trajectory.
Compare the eigenvalues of PC1 and PC2 and inspect their eigenvectors.
Identify if the protein is exploring a single large state or jumping between different ones.
Retrieve the Principal Axes of the Amyloid-Beta fibril (2BEG) and check which axis is the longest (the fibril’s length).
You now know how to extract the essence of molecular motion. In Module 36, we will go back to the fold and analyze the Secondary Structure of our proteins.