<div dir="ltr">I've been working through the tutorial again, and I now see (and understand) the randomization step that is part of cross validation. I'm so glad Adegenet has this formalized test. Thanks so much.<div><br><div>C<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 18, 2014 at 5:41 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi there,<br>
<br>
no need to recode everything: what you describe is cross-validation, and it is implemented in adegenet. See ?xvalDapc<br>
<br>
Cheers<br>
<br>
Thibaut<br>
<br>
<br>
________________________________________<br>
From: Caroline Judy [<a href="mailto:caroline.duffie@gmail.com">caroline.duffie@gmail.com</a>]<br>
Sent: 16 September 2014 21:45<br>
To: Jombart, Thibaut<br>
Cc: Vikram Chhatre; <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<span class="">Subject: [adegenet-forum] randomize pop labels in a genind object for randomization experiment.<br>
<br>
</span><span class="">Hi Thibaut, Vikram, and others:<br>
<br>
I'd like to try a randomization experiment to further explore my radseq data using DAPC.<br>
<br>
Data structure:<br>
40 individuals in 2 (apriori) populations<br>
6451 SNP loci<br>
<br>
My data are for two very closely related "species" which show little to no divergence at traditional markers. I performed a DAPC using a priori pop definitions (set as species). The function can discriminate my species, but the allelic contributions are very low ( highest few around .0015).<br>
<br>
I am interested in trying a randomization experiment in which I shuffle the population labels 100 times and then perform DAPC on each of these. Ultimately the goal is to compare allelic loadings for the discriminant function generated using true labels vs. randomized labels.<br>
<br>
I am fairly new to R. A colleague suggested the general format to create a loop, but could anyone offer a solution that could be implemented with a genind object? Otherwise, I think it would be too labor intensive - I would have to create 100 different structure input files to be converted to genind objects.<br>
<br>
nrep<- 100<br>
results<- list() # or vector/matrix, depending on the case<br>
For(I in 1:nrep)<br>
{<br>
Rand.labels<- sample(labels)<br>
## do some analyses and assign relevant results to results<br>
}<br>
<br>
Thanks,<br>
Caroline<br>
<br>
<br>
</span><span class="">On Sun, Sep 14, 2014 at 3:45 PM, Jombart, Thibaut <<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>>> wrote:<br>
<br>
Yes, you need to use:<br>
?genind2hierfstat<br>
<br>
Cheers<br>
Thibaut<br>
<br>
________________________________________<br>
</span>From: Vikram Chhatre [<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>>]<br>
<span class="">Sent: 13 September 2014 21:48<br>
</span>To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>>; Jombart, Thibaut<br>
<span class="">Subject: Re: [adegenet-forum] Per locus pairwise Fst<br>
<br>
Thank you for all the replies. I have been looking at the pp.fst() function in the Hierfstat package. Does the post-seploc data frame need to be converted into something that Hierfstat understands first? The following doesn't seem to work:<br>
<br>
# Use seploc to separate loci:<br>
gen100_seploc <- seploc(gen100_genind, truenames=TRUE, res.type=c('genind', 'matrix')<br>
<br>
# Load Hierfstat<br>
library(hierfstat)<br>
<br>
# Calculate pairwise Fst:<br>
gen100_perLocusPWFst <- lapply(gen100_seploc, pp.fst, diploid=TRUE)<br>
<br>
Error in unique.default(Pop) : unique() applies only to vectors<br>
<br>
</span><span class="">On Sat, Sep 13, 2014 at 2:20 PM, Jombart, Thibaut <<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>>>> wrote:<br>
<br>
Hi there,<br>
<br>
</span><span class="">yes, this function is not optimized for large datasets. You can use the same approach but using functions from the hierfstat package.<br>
<br>
Cheers<br>
Thibaut<br>
________________________________________<br>
</span><span class="">From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>>> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>>>] on behalf of Vikram Chhatre [<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>>>]<br>
</span><span class="">Sent: 12 September 2014 18:31<br>
</span><span class="">To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>>><br>
</span><span class="">Subject: Re: [adegenet-forum] Per locus pairwise Fst<br>
<br>
I am revisiting this topic due to some technical problems.<br>
<br>
The task at hand is to estimate pairwise Fst matrices for each locus separately.<br>
<br>
# Genind object is stored in:<br>
gen100_genind<br>
<br>
# Use seploc to separate loci:<br>
gen100_seploc <- seploc(gen100_genind, truenames=TRUE, res.type=c('genind', 'matrix')<br>
<br>
# Calculate pairwise Fst:<br>
gen100_perLocusPWFst <- lapply(gen100_seploc, pairwise.fst, res.type=c('dist', 'matrix'), trunames=TRUE)<br>
<br>
For a data set consisting of 30 populations, 20 individuals each, 1000 loci and 2 alleles per locus (1.2 million data points), it takes up to 6 hours to estimate the pairwise Fst matrix with this method.<br>
<br>
Is there any way to speed this up? Should I look into any other packages?<br>
<br>
Many thanks for your time and help.<br>
Vikram<br>
<br>
<br>
<br>
<br>
</span><span class="">On Mon, Jul 14, 2014 at 9:16 AM, Vikram Chhatre <<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>>>>> wrote:<br>
Perfect! Thank you for both solutions.<br>
<br>
V<br>
<br>
<br>
</span><span class="">On Mon, Jul 14, 2014 at 9:13 AM, Jombart, Thibaut <<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>>><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a><mailto:<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>>>>> wrote:<br>
<br>
Hi there,<br>
<br>
you can use seploc to separate loci, and lapply over the resulting list using your prefered fst function.<br>
<br>
Cheers<br>
Thibaut<br>
________________________________________<br>
</span>From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>>>> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>>>>] on behalf of Vikram Chhatre [<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a><mailto:<a href="mailto:crypticlineage@gmail.com">crypticlineage@gmail.com</a>>>>]<br>
<span class="">Sent: 14 July 2014 14:01<br>
</span>To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>>><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>>>><br>
<span class="">Subject: [adegenet-forum] Per locus pairwise Fst<br>
<br>
Good morning.<br>
<br>
I would like to estimate per locus pairwise Fst for populations, but it appears that Adegenet only estimates this over all loci (i.e. single matrix). What I would like is one matrix per locus. Has anyone modified the functions or know of alternative programs that can do this?<br>
<br>
Thanks<br>
Vikram<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
adegenet-forum mailing list<br>
</span><a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><mailto:<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a>><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
</blockquote></div><br></div></div></div></div>