# [adegenet-forum] (no subject)

Jombart, Thibaut t.jombart at imperial.ac.uk
Tue Feb 1 18:05:08 CET 2011

```Dear Rudy,

thanks for reposting your question on the forum. Kmeans clustering does not give probabilities of assignment of one individual cluster, but discriminant analysis does. After doing your DAPC analysis with the clusters defined by find.clusters, these probabilities are stored in \$posterior; also see 'summary' for averages of successful assignment per groups. Note that the result depends on the number of principal components retained in the DAPC step. Please have a look at ?a.score and at the posts on the forum about this topic (search the archives for "a.score", see 'contact section on the website).

Here's a simple example using one of the simulated datasets of the DAPC paper:
###
> data(dapcIllus)
> x=dapcIllus\$a
> grp=find.clusters(x, n.pca=20, n.clust
> dapc1 = dapc(x, pop=grp\$grp, n.pca=20, n.da=100) # retain all discriminant functions, n.pca is arbitrary
> scatter(dapc1)
> head(dapc1\$posterior) # these are the proba of assignment of individuals (in row) to groups
1            2            3            4         5            6
001 1.117731e-08 3.121147e-03 2.451437e-05 3.424392e-08 0.9968310 2.333178e-05
002 1.906086e-15 4.588542e-14 1.508931e-14 4.006893e-11 1.0000000 1.473177e-13
003 2.700339e-10 8.584223e-13 1.330813e-10 8.821750e-12 1.0000000 6.636315e-11
004 7.611857e-09 8.791814e-08 1.145752e-07 2.186551e-07 0.3800647 6.199349e-01
005 5.454810e-10 1.810788e-13 8.479315e-13 3.848505e-09 0.9999998 1.629225e-07
006 5.531436e-10 4.806872e-12 1.696606e-11 3.232611e-07 0.9999861 1.356142e-05
###

One plot designed to represent this information is the assignplot; e.g. for the first 10 individuals:
###
> assignplot(dapc1,subset=1:10)
###

See ?assignplot.

However, optim.a.score tells us that 20 PCs (n.pca=20) is probably an overkill, and there are risks of over-fitting. According to:
> optim.a.score(dapc1, smart=FALSE)
5 PCs should be our best option.

So, we can just re-run the DAPC and then interprete assignments, e.g.:
> dapc1 = dapc(x, pop=grp\$grp, n.pca=5, n.da=100)
> assignplot(dapc1,subset=1:30)
> summary(dapc1)\$assign.per.pop # re-assignment
> a.score(dapc1, n.sim=50)\$pop.score # corrected re-assignment

Best regards,

Thibaut

________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] On Behalf Of Jonker, Rudy [Rudy.Jonker at wur.nl]
Sent: 01 February 2011 13:51
To: 'adegenet-forum at lists.r-forge.r-project.org'
Subject: [adegenet-forum] (no subject)

Dear Thibaut,

I am using your program DAPC to define the number of clusters in a dataset of 400 individuals and 374 SNPs. With find.clusters I get a assignment per individual to each cluster. What I am looking for is the probability of assignment to each of the (for example) 3 groups, when k=3. The idea is to make a graph like figure 4 in the attached paper.

Is that possible? I think it should be because within the find.clusters the program must use some stats in the assignment of the clusters to each individual. When I use the \$posterior command on the clusterfile it gives me NULL as answer. And the posterior command gives with predefined groups only 0 or 1 for the probabilities of assignment, corresponding to what was predefined.