This is a test version of Biostars. For the public version, visit https://www.biostars.org.
SNPRelate; Plot looking blank

I am doing PCA analysis through SNPRelate. Its Generating the PCA plot but completely blank without any error. What to do?

Other question is that how can I add population information in my .gds file as I am working on a plant species. SNPRelate tutorial example file is working very smoothly but I its not user friendly for others.

snprelate

Can you post the piece of code that you are using ?

> # make a data.frame
> tab <- data.frame(sample.id = pca$sample.id,
+ EV1 = pca$eigenvect[,1], # the first eigenvector
+ EV2 = pca$eigenvect[,2], # the second eigenvector
+ stringsAsFactors = FALSE)
> head(tab)
  sample.id         EV1         EV2
1   NA19152  0.08411287  0.01226860
2   NA19139  0.08360644  0.01085849
3   NA18912  0.08110808  0.01184524
4   NA19160  0.08680864  0.01447106
5   NA07034 -0.03109761 -0.07709255
6   NA07055 -0.03228450 -0.08155730
> # draw
> plot(tab$EV2, tab$EV1, col=as.integer(tab$pop),
+ xlab="eigenvector 2", ylab="eigenvector 1")

Note: Results are generated from .gds file

One possibility could be the eigenvectors EV1 or EV2 contains NaN as values. You can check the actual value by just typing pca$eigenvect[,1] or pca$eigenvect[,2]

but values are there in file as you look at my previous comment

Then the problem is with the col=as.integer(tab$pop) as I could not see any column pop in the tab data structure.

How can I add this column in my data, because in SNPRelate documentation, it is not written.

1 answer

Hi, Although this is an older post but if someone is looking for the answer, here I found one on add column to dataframe r- https://www.hdfstutorial.com/blog/add-column-to-dataframe-r/ Using this you will be able to add a new column at the place you want.

Log in to answer this question.