gitmyhub

QuickPCA

Python ★ 33 updated 1mo ago

💠 A streamlined worfklow for Principal Component Analysis of molecular dynamics in PyMOL

A Python script that runs inside PyMOL to apply Principal Component Analysis to molecular dynamics simulations, finding the most meaningful protein motions.

PythonNumPySciPyscikit-learnMatplotlibPyMOLsetup: moderatecomplexity 3/5

QuickPCA is a Python tool for analyzing molecular dynamics simulations inside PyMOL, a widely used molecular visualization program. It takes simulation data, where proteins and other molecules are tracked atom by atom over thousands of frames, and applies a mathematical technique called Principal Component Analysis (PCA) to find the most meaningful patterns in all that movement.

When you run a molecular dynamics simulation on a protein with 1,000 atoms for 10,000 frames, you end up with 30 million data points. PCA cuts through that noise by identifying which atomic motions are just random jitter and which ones represent real, functionally important movement. QuickPCA focuses on this approach to "essential dynamics" and compresses those thousands of dimensions down to the two most informative directions, called PC1 and PC2.

What sets QuickPCA apart from standard PCA methods is how it does the math. Instead of building and then diagonalizing a covariance matrix, which can be slow and numerically fragile, it uses a technique called SVD (Singular Value Decomposition) directly on the raw data matrix. The results are identical to the standard approach but computed faster and more reliably. The residue cross-correlation matrix, which shows how movement in one part of the molecule tracks with movement in another, is then recovered analytically without re-reading the original trajectory data.

After running, QuickPCA generates a single report image (PCA_Report.png) containing four panels: a free-energy landscape, a residue cross-correlation map, an explained variance profile, and principal component projection distributions. The workflow is minimal: drop the script into the same folder as your structure and trajectory files, open the structure in PyMOL, and drag the script into the PyMOL window.

The tool supports common trajectory formats (.xtc, .trr, .dcd, .nc) and runs on Windows, Linux, and MacOS. It depends on standard scientific Python libraries: NumPy, SciPy, scikit-learn, and Matplotlib.

Where it fits