# Calculation Principal Component analysis (PCA)

**URL:** https://gromacs.bioexcel.eu/t/calculation-principal-component-analysis-pca/3368
**Category:** User discussions
**Created:** [December 26, 2021, 7:15am UTC](https://gromacs.bioexcel.eu/t/calculation-principal-component-analysis-pca/3368 "2021-12-26T07:15:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![farial.t](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@farial.t](https://gromacs.bioexcel.eu/u/farial.t)
#### Post date: [December 26, 2021, 7:15am UTC](https://gromacs.bioexcel.eu/t/calculation-principal-component-analysis-pca/3368/1 "2021-12-26T07:15:00Z")

</div>

GROMACS version: 2018  
GROMACS modification: Yes/No no  
Here post your question

Dear GROMACS users

I need to investigate the effects of a duplication mutation in my protein structure and function. It is needed to calculate protein motion and free energy landscape analyses.  
issued this command to calculate eigenvec.trr and eigenvalue.xvg  
gmx covar -f nopbc.xtc -s .tpr  
and now I want to compute PCA but I don’t know the exact  
“gmx anaeig” command I should use.  
I would be really grateful if someone can help me to understand and calculate it.

Thanks in advance  
Farial

---

<div class="post-metadata">

### Author: ![georgian](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@georgian](https://gromacs.bioexcel.eu/u/georgian)
#### Post date: [January 28, 2022, 2:08pm UTC](https://gromacs.bioexcel.eu/t/calculation-principal-component-analysis-pca/3368/2 "2022-01-28T14:08:37Z")

</div>

You can try along the following lines:  
gmx\_mpi covar -f out.xtc -s md.gro -n index.ndx -ascii -v eigenvec.trr -tu ns -last 2  
gmx\_mpi anaeig -v eigenvec.trr -f out.xtc -s md.tpr -proj pc1.xvg -first 1 -last 1 (replace 1 with 2 from 2nd eigenvector)

thank you

---

<div class="post-metadata">

### Author: ![farial.t](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@farial.t](https://gromacs.bioexcel.eu/u/farial.t)
#### Post date: [February 6, 2022, 8:14am UTC](https://gromacs.bioexcel.eu/t/calculation-principal-component-analysis-pca/3368/3 "2022-02-06T08:14:39Z")

</div>

Dear Georgian

Thank you for replying

I issued these commands to calculate the covariance matrix:  
gmx covar -f nopbc.xtc -s .tpr

and then issued this command to obtain 2dproj.xvg  
gmx anaeig --v eigenvec.trr -f nopbc.xtc -s .tpr -eig eigenval.xvg -sd 2dproj.xvg -first 1 -last 2

is that wrong?

---

<div class="post-metadata">

### Author: ![georgian](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@georgian](https://gromacs.bioexcel.eu/u/georgian)
#### Post date: [February 16, 2023, 9:07am UTC](https://gromacs.bioexcel.eu/t/calculation-principal-component-analysis-pca/3368/4 "2023-02-16T09:07:23Z")

</div>

> [@georgian](#):
>
> eigenvec.trr

you didn’t mention the last PC to be consider by using the "-last " flag as the command above -last 2 was used meaning only the first two PCs will be in the output files.
