library(bio3d) ## reads a PDB file as reference. must have the same number of atoms as your trajectory file pdb <- read.pdb("Pdb_file_with_the_same_number_of_atoms.pdb") ## reads your trajectory trj <- read.dcd("my_nice_dcd_traj_file") ## finds the CA atoms ca.inds <- atom.select(pdb, "calpha") ## performs the PCA pc.traj <- pca.xyz(trj[, ca.inds$xyz]) ## plots it plot(pc.traj) ## make a trajectory for visualization in VMD a <- mktrj.pca(pc.traj, pc=1, file="pc1.pdb")