Examining Principal Components of Genetic Ancestry in R
2
0
Entering edit mode
7.9 years ago
tesfadej2003 ▴ 10

Hi All,

I want to examine the population structure using genotyped data. Using the smartpca program from the eigensoft package, I calculated principal components of genetic data using 'smartpca -p mydata > pca.log' command. Finally, I have got a lot of stuff in the file name 'pca.log' including removal of outliers (5 iteration), Tracy-Widom statistics, top 10 eigvalues, 10 eigenvector..etc.

Now, i don't have any idea how to plot the population structure in R software package. Does anyone have R script to plot using the first two principal components of genetic ancestry?

Thank you for your time!

PCA R • 4.0k views
ADD COMMENT
1
Entering edit mode
7.9 years ago

I think this page has what you're looking for.

ADD COMMENT
0
Entering edit mode

First of all, thank you very much for your helpful hint. I have seen it the link and tried to adopt it. However, it is not working. I understood all the outputs from 'smartpca -p Itamba.par > Itamba.out' should be in the file 'Itamba.out'. So, 'Itamba_PCA.evec' and 'Itamba_PCA.eval' were not created as separate output file and I couldn't find inside 'Itamba.out' output file. Is there a way to create these two output files from the main output file ('Itamba.out')? Becuase it has been used separately.

Thank you in advance.

ADD REPLY
0
Entering edit mode

Not all the output is in one file. The output file names are specified in a configuration file. In this example, the configuration file is called Itamba.par and in this file, the file 'Itamba_PCA.evec' (containing the PCs/eigenvectors) should be specified as value for the parameter named 'evecoutname' i.e. as
'evecoutname:'Itamba_PCA.evec'. Same for eigenvalues and parameter 'evaloutname'. These parameters should be required so check that you have specified the correct file name/path and/or that you don't get any error message.

ADD REPLY
0
Entering edit mode

Now, it is fine. I am grateful. I owe you.

ADD REPLY
0
Entering edit mode
7.9 years ago
anp375 ▴ 190

Samples Eigenvector1 Eigenvector2 Eigenvector3 ... EigenvectorX

Sample1 Xcoord_____Ycoord_____Zcoord

Sample2 Xcoord_____Ycoord_____Zcoord

. . .

SampleN Xcoord_____Ycoord_____Zcoord

Plot 1 point for each sample using two of the three coordinates. Or plot all three at the same time using this package: https://cran.r-project.org/web/packages/pca3d/pca3d.pdf

ADD COMMENT
0
Entering edit mode

Thank you. You gave me hint to plot 3D. What I need is to plot 2D?

ADD REPLY

Login before adding your answer.

Traffic: 2051 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6