Dear Thibaut,<br><br>Sorry, I accidentally switched 'pop1' and 'pop2' in my description of 'popx'; it should read:<br> 'popx' is a mix of individuals from;<br>
- about 80% of individuals belonging to 'pop2'<br> - about 15% of individuals belonging to 'pop1'<br> - about 5% of hybrid individuals between 'pop1' and 'pop2'.<br><br>For the reclassification of individuals from popx into pop1 and pop2, indeed, the second approach you propose seems the best. I was previously using the 'seppop' function to separate the genind object into 3 objects (corresponding to each population) and then using the 'repool' function to merge 2 of these objects. By doing this, alleles with no data are dropped when using the 'repool' function (the 'drop' option is not implemented in 'repool'). However, by subsetting directly 2 populations from the original genind object ('2pop=3pop[3pop@pop %in% c("P1","P2"),drop=FALSE]'), we do not need to use the 'repool' function so that alleles with no data are kept. <br>
Concerning the wrapper for 'predict.lda', I'm not too sure how best to code that.<br><br>Thanks for your help,<br><br>Sebastien.<br><br><div class="gmail_quote">On 22 March 2011 17:36, Jombart, Thibaut <span dir="ltr"><<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hello,<br>
<br>
There is something that confuses me in your description. 80% of individuals in popx are from pop1, 15% from pop2, the rest are hybrids.So why is it unexpected that the distinction between pop2 and popx is made clearer on the 'partial DAPC' approach? On the contrary, you expect this analysis to distinguish pop1 from pop2, so if popx is mainly pop1, we expect differences between popx and pop2 to be emphasized.<br>
<br>
Concerning the probabilities of assignment of individuals to the three groups, this is because popx still contributes to the variability between groups - only there is no longer an effect of alleles that are specific to popx. If you want to reclassify individuals from popx into pop1 and pop2 only, then a different and probably cleaner approach needs to be used. Alleles from popx that do not exist in pop1 and pop2 will not be missing data, but the analysis will need to be done without pruning these alleles (in the subset function "[" of genind object, there's an option 'drop' which needs to be set to FALSE). Then what you will need is a wrapper for 'predict.lda' for dapc objects. This does not exist yet, but it fairly straightforward to code. Contribution welcome if you want to give it a go, otherwise I will likely sort this out over the coming days, as soon as I've got time to devote to adegenet that is.<br>
<br>
All the best<br>
<br>
Thibaut<br>
<br>
<br>
<br>
<br>
________________________________________<br>
From: Sébastien Puechmaille [<a href="mailto:s.puechmaille@gmail.com" target="_blank">s.puechmaille@gmail.com</a>]<br>
Sent: 21 March 2011 19:12<br>
To: Jombart, Thibaut<br>
Cc: <a href="mailto:adegenet-forum@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum@r-forge.wu-wien.ac.at</a><br>
Subject: Re: [adegenet-forum] Genotypes assignment to clusters<br>
<div><br>
Dear Thibaut,<br>
<br>
Thanks very much for this solution. Indeed, the question was "how to assign individuals from one space to groups defined in another, partially overlapping space"?<br>
<br>
I've run this analysis with the real dataset (not the toy dataset presented in the previous e-mail) and compared the results with and without regression. What I should probably mention here is that the group 'popx' is a mix of individuals from;<br>
- about 80% of individuals belonging to 'pop1'<br>
- about 15% of individuals belonging to 'pop2'<br>
- about 5% of hybrid individuals between 'pop1' and 'pop2'.<br>
<br>
For the data set without regression, I performed a 'normal' DAPC with 3 predefined groups 'pop1, 'pop2' and 'popx'.<br>
-'pop1' individuals are clearly differentiated from 'pop2' and 'popx'<br>
-'pop2' and 'popx' individuals are nearly indiscernable along discriminant function 1 (except for a few individuals from 'popx' that in fact belong to 'pop1')<br>
- the mean comparison of inferred groups with actual groups is 0.62<br>
<br>
For the data set with regression, I performed a 'normal' DAPC on the residuals of the regression (as detailed in the previous e-mail)<br>
-'pop1' individuals are again clearly differentiated from 'pop2' and 'popx'<br>
-'pop2' and 'popx' individuals are much more differentiated along discriminant function 1 when compared to the normal DAPC detailed above.<br>
- the mean comparison of inferred groups with actual groups is 0.81 (more than the normal DAPC)<br>
This accentuated differentiation of 'pop2' and 'popx' individuals seems rather unexpected as most individuals from 'popx' are in fact from 'pop2' (see details above). Also, after the DAPC, each individual has a probability to belong to the 3 groups ('pop2', 'pop1' and 'popx') rather than 2 groups ('pop2' and 'pop1') as aimed.<br>
<br>
Give that original alleles of the 'popx' population, present in the 'popx' population but absent from either source populations (pop1 or pop2), wont give us any information about the origin of the 'popx' individuals (e.i. whether they come from 'pop1' or 'pop2), when performing the 'normal' DAPC (without regression), could we 'simply' consider these original alleles of 'popx' as missing data? Would there be an easy way to do that?<br>
<br>
Thanks again for your help,<br>
<br>
Sébastien.<br>
<br>
</div><div>On 21 March 2011 15:34, Jombart, Thibaut <<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>>> wrote:<br>
Dear Sébastien,<br>
<br>
thanks for this very interesting question. To rephrase it: "how to assign individuals from one space to groups defined in another, partially overlapping space"?<br>
<br>
The problem is not trivial if we think of it in probabilistic terms. If you used Bayesian/likelihood-based clustering, clusters would be defined in terms of frequencies of a given set of alleles (say, "S"). You can compute the probability for an individual to come from cluster xxx (or a mixture of clusters xxx, yyy, zzz etc in admixture models) as long as this individual does not possess any original allele (i.e., not in 'S'). Would it not be the case, the probability of observing a new allele in the previously defined clusters is, by definition, zero and thus P=0 for all clusters. Annoying.<br>
<br>
Distance-based method have a similar problem: if the spaces differ, it is much more difficult to compare one individual to another.<br>
<br>
However, we can use the fact that one space is contained within another, namely, the alleles differentiating pop1 /vs/ pop2 are a subset of the alleles of the complete dataset. One approach is to use an analysis that we could run on the entire dataset, but that would exclude all originality of 'popx', and only conserve differences between 'pop1' and 'pop2'. This can be achieved by regressing the data onto a factor opposing 'popx' to 'non-pop-x' individuals.<br>
<br>
####<br>
X <- truenames(trial)$tab # extract table of allele frequencies<br>
popx <- factor(pop(trial)=="popx") # popx vs non-popx<br>
X.res <- apply(X,2, function(e) residuals(lm(e~popx))) # remove 'popx' effect<br>
<br>
dapc1 <- dapc(X.res, pop(trial), n.pca=3, n.da=1) # perform dapc<br>
scatter(dapc1)<br>
assignplot(dapc1)<br>
####<br>
<br>
The DAPC aims to discriminate all populations of the dataset, but we actually tricked the method by removing all originality specific to "popx" beforehand. With the toy dataset you sent, "popx" is actually still at one extreme of the cline, but I suspect that actually hybrid populations should fall between the two parental populations.<br>
<br>
<br>
Best regards<br>
<br>
Thibaut.<br>
<br>
<br>
--<br>
######################################<br>
Dr Thibaut JOMBART<br>
MRC Centre for Outbreak Analysis and Modelling<br>
Department of Infectious Disease Epidemiology<br>
Imperial College - Faculty of Medicine<br>
St Mary’s Campus<br>
Norfolk Place<br>
London W2 1PG<br>
United Kingdom<br>
Tel. : 0044 (0)20 7594 3658<br>
</div><a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>><br>
<div><a href="http://sites.google.com/site/thibautjombart/" target="_blank">http://sites.google.com/site/thibautjombart/</a><br>
<a href="http://adegenet.r-forge.r-project.org/" target="_blank">http://adegenet.r-forge.r-project.org/</a><br>
<br>
________________________________________<br>
</div>From: <a href="mailto:adegenet-forum-bounces@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum-bounces@r-forge.wu-wien.ac.at</a><mailto:<a href="mailto:adegenet-forum-bounces@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum-bounces@r-forge.wu-wien.ac.at</a>> [<a href="mailto:adegenet-forum-bounces@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum-bounces@r-forge.wu-wien.ac.at</a><mailto:<a href="mailto:adegenet-forum-bounces@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum-bounces@r-forge.wu-wien.ac.at</a>>] On Behalf Of Sébastien Puechmaille [<a href="mailto:s.puechmaille@gmail.com" target="_blank">s.puechmaille@gmail.com</a><mailto:<a href="mailto:s.puechmaille@gmail.com" target="_blank">s.puechmaille@gmail.com</a>>]<br>
<div>Sent: 21 March 2011 13:15<br>
</div>To: <a href="mailto:adegenet-forum@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum@r-forge.wu-wien.ac.at</a><mailto:<a href="mailto:adegenet-forum@r-forge.wu-wien.ac.at" target="_blank">adegenet-forum@r-forge.wu-wien.ac.at</a>><br>
<div><div></div><div>Subject: [adegenet-forum] Genotypes assignment to clusters<br>
<br>
Dear Thibaut and Adegenet users,<br>
<br>
I have a data set with 3 groups of samples (see below), 2 with samples of known origin (pop1 and pop2) and one (popx) with samples that I would like to assign to one of the 2 known populations (pop1 or pop2). For this, I want to run a DAPC with 'pop1' and 'pop2' data set and then, assign individuals from 'popx' to either 'pop1' or 'pop2'.<br>
<br>
However, individuals from the group to be assigned have some private alleles that are neither in 'pop1' nor in 'pop2' and therefore, the assignment cannot work. What would be the best solution to get around this problem?<br>
Shall I create dummies individuals in 'pop1' and 'pop2' having the private alleles of 'popx'?<br>
<br>
Hereafter is a reduced data set to illustrate the problem:<br>
indiv pop L1 L2 L3<br>
Indiv1 pop1 222224 232224 120122<br>
Indiv2 pop1 222226 232226 118120<br>
Indiv3 pop1 222222 232232 120120<br>
Indiv4 pop1 222224 232224 124124<br>
Indiv5 pop2 224224 224224 122122<br>
Indiv6 pop2 224224 224224 124124<br>
Indiv7 pop2 224226 224226 120120<br>
Indiv8 pop2 222224 232224 122124<br>
Indiv9 popx 220222 220232 116118<br>
Indiv10 popx 222224 232224 118120<br>
Indiv11 popx 222226 232226 120120<br>
Indiv12 popx 224224 224224 124124<br>
<br>
<br>
geno<-read.table("three-pop.txt",h=T)<br>
<br>
trial<-df2genind(geno[,3:5],missing=NA,ploidy=2,sep=NULL,ncode=6,ind.names=geno[,1], loc.names=colnames(geno[1,3:5]),pop=geno[,2])<br>
<br>
trial@pop.names<br>
split<- seppop(trial)<br>
<br>
pop12 <- repool(split$pop1, split$pop2)<br>
<br>
pop12 @all.names<br>
split$popx@all.names<br>
<br>
In this case, 'pop12' has 10 columns of '@tab' while 'split$popx' has 13 columns of '@tab'.<br>
<br>
Would anyone have a solution or any advice?<br>
<br>
Thanks for your help,<br>
<br>
Sébastien.<br>
<br>
<br>
*********************<br>
Dr. Sébastien Puechmaille<br>
UCD School of Biological and Environmental Sciences<br>
University College Dublin (Zoology)<br>
UCD Science and Education Research Center (West)<br>
Belfield<br>
Dublin 4<br>
Ireland<br>
<br>
and<br>
<br>
Max Planck Institute for Ornithology<br>
Sensory Ecology Group<br>
Eberhard-Gwinner-Straße<br>
Haus Nr. 11<br>
82319 Seewiesen<br>
Germany<br>
<br>
</div></div><a href="http://batlab.ucd.ie/%7Espuechmaille/" target="_blank">http://batlab.ucd.ie/~spuechmaille/</a><<a href="http://batlab.ucd.ie/%7Espuechmaille/" target="_blank">http://batlab.ucd.ie/%7Espuechmaille/</a>><br>
<div><div></div><div><a href="http://www.ucd.ie/research/people/biologyenvscience/drsebastienpuechmaille/home/" target="_blank">http://www.ucd.ie/research/people/biologyenvscience/drsebastienpuechmaille/home/</a><br>
*********************<br>
</div></div></blockquote></div><br>