Problem with reading Genalex file

219 views
Skip to first unread message

Aasim Majeed

unread,
Apr 23, 2017, 2:41:23 PM4/23/17
to poppr
I am using poppr for the first time and I am also new to R. I have non stratified data, 27 microsattellite loci and 260 individuals.

While performing DAPC analysis I got following: 
details;

library("adegenet")
data(genalex) 
pop(genalex) <- genalex$other$epid
dapc.genalex <- dapc(genalex, var.contrib = TRUE, scale = FALSE, n.pca = 30, n.da = nPop(genalex) - 1)
scatter(dapc.genalex, cell = 0, pch = 18:23, cstar = 0, mstree = TRUE, lwd = 2, lty = 2)

Error:
Error in dapc.genind(genalex, var.contrib = TRUE, scale = FALSE, n.pca = 30,  : 
  x does not include pre-defined populations, and `pop' is not provided
> scatter(dapc.genalex, cell = 0, pch = 18:23, cstar = 0, mstree = TRUE, lwd = 2, lty = 2)
Error in scatter(dapc.genalex, cell = 0, pch = 18:23, cstar = 0, mstree = TRUE,  : 
  object 'dapc.genalex' not found

please provide solution

Zhian Kamvar

unread,
Apr 23, 2017, 2:54:10 PM4/23/17
to poppr
Hi, 

From the example you have shown, it does not appear that you have imported your data. If you have your data in genalex format, you can use read.genalex("/path/to/file"), where you replace "/path/to/file" with the actual path to your data on your computer.

Additionally, it is important to note that dapc is a function from adegenet. I have seen a few citations for poppr floating around that use dapc and do not cite adegenet. 

The data() function is for use with examples only. These examples live within the package, so using data(genalex) should have no effect. In fact, your script should render an error on line three. 

Please read through the DAPC tutorial found here: https://github.com/thibautjombart/adegenet/wiki/Tutorials for information on the error. To conduct DAPC, you must have pre-defined groups. If you don't have pre-defined groups/populations, you can use k-means clustering with find.clusters, but be careful with the downstream analyses as you do not want to fall into the trap of comparing the differentiation of pre-defined groups (See Meirmans, 2015 for details: http://www.molecularecologist.com/2015/05/conversation-starter-common-mistakes-in-population-genetics/).

Hope that helps,
Zhian
Reply all
Reply to author
Forward
0 new messages