From t.jombart at imperial.ac.uk Tue Jun 4 12:13:14 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Tue, 4 Jun 2013 10:13:14 +0000 Subject: [adegenet-forum] xvalDapc error message In-Reply-To: References: Message-ID: <2CB2DA8E426F3541AB1907F98ABA65706386D05E@icexch-m1.ic.ac.uk> Hello, In your case, cross-validation is bound to be problematic. The distribution of your groups is: > table(grp) grp 1 2 3 4 5 6 7 24 6 9 4 22 24 33 With large training sets, chances some groups won't be cross-validated - in this case, the devel version now issues a meaningful warning. With small training sets, some groups may not be represented at all, causing the discriminating space to skrink by one or more dimension, and currently causing a more cryptic error. I am still wondering what the best default behaviour should be in this case. Short solution for you is to specify n.da and fix a value of e.g. 4, so that the dimension of your discriminating space does not have to be determined by the number of groups. But the core problem remain - largely unequal group sizes in overall small dataset are not well suited for cross validation. Cheers Thibaut ________________________________________ From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Julian Dupuis [jrdupuis at ualberta.ca] Sent: 31 May 2013 20:06 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] xvalDapc error message Hello, I am trying to use the new xvalDapc function to determine the ideal number of PCs to retain in my DAPC analysis, but am having trouble getting it to work. Here's the code I'm inputting: xval <- xvalDapc(JRD1NoNa at tab, pop(JRD1), n.pca.max=150, n.da=NULL, n.pca=NULL, center=TRUE, scale=FALSE, n.rep=10) And this is the error message I receive: Error in ldaX$scaling[, 1:n.da, drop = FALSE] : subscript out of bounds I've searched around for similar problems, but haven't found anything relating specifically to the lda function in MASS. I'm wondering if it might just be a problem with MASS being out of date with the new version of R/adegenet? Any help would be appreciated, and please let me know if I could include anything else to help identify the problem (my R expertise is pretty minimal). Also, if anyone has any insight/opinions on alternate ways to determine the ideal number of PCs to retain in a DAPC (e.g. the optim.a.score function), I would be interesetd to hear them. Thanks in advance, Julian Dupuis -- Julian Rowe Dupuis Ph.D. Candidate Dept of Biological Sciences CW405, Biol. Sci. Centre University of Alberta Edmonton, Alberta, CAN T6G 2E9 Office: Earth Sciences 1-52A From zkamvar at gmail.com Thu Jun 27 00:05:43 2013 From: zkamvar at gmail.com (Zhian Kamvar) Date: Wed, 26 Jun 2013 15:05:43 -0700 Subject: [adegenet-forum] seploc resets ploidy information to diploid Message-ID: Hello, I was working on some analyses dealing with polyploids, and I noticed that seploc resets the ploidy information of each locus to diploid, regardless of initial ploidy. For a simplified example, here's your example from the adegenet-basics.pdf: > temp <- lapply(1:30, function(i) sample(1:9, 4, replace=TRUE)) > > temp <- sapply(temp, paste, collapse="") > > temp <- matrix(temp, nrow=10, dimnames=list(paste("ind",1:10), > paste("loc",1:3))) > > obj <- df2genind(temp, ploidy=4, sep="") > > objloc <- seploc(obj) > > sapply(objloc, ploidy) > loc 1 loc 2 loc 3 > 2 2 2 > > ploidy(obj) > [1] 4 > I went into the adegent source code and found where the trouble was. It's on line 99 of "handling.R": kX <- lapply(kX, genind, pop=x at pop, prevcall=prevcall) > To preserve ploidy, I think this line should be: kX <- lapply(kX, genind, pop=x at pop, prevcall=prevcall, ploidy = x at ploidy) > Can this be implemented in the next version of adegenet? Thanks, Zhian N. Kamvar -------------- next part -------------- An HTML attachment was scrubbed... URL: From t.jombart at imperial.ac.uk Fri Jun 28 12:26:34 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Fri, 28 Jun 2013 10:26:34 +0000 Subject: [adegenet-forum] seploc resets ploidy information to diploid In-Reply-To: References: Message-ID: <2CB2DA8E426F3541AB1907F98ABA65706387EE7C@icexch-m1.ic.ac.uk> Dear Zhian, many thanks for spotting this! I'll make the change straight away, and the next release of adegenet will incorporate it. Meanwhile, the fixed devel version will be available from sourceforge: https://sourceforge.net/projects/adegenet/?source=directory Best Thibaut ________________________________________ From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Zhian Kamvar [zkamvar at gmail.com] Sent: 26 June 2013 23:05 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] seploc resets ploidy information to diploid Hello, I was working on some analyses dealing with polyploids, and I noticed that seploc resets the ploidy information of each locus to diploid, regardless of initial ploidy. For a simplified example, here's your example from the adegenet-basics.pdf: > temp <- lapply(1:30, function(i) sample(1:9, 4, replace=TRUE)) > temp <- sapply(temp, paste, collapse="") > temp <- matrix(temp, nrow=10, dimnames=list(paste("ind",1:10), paste("loc",1:3))) > obj <- df2genind(temp, ploidy=4, sep="") > objloc <- seploc(obj) > sapply(objloc, ploidy) loc 1 loc 2 loc 3 2 2 2 > ploidy(obj) [1] 4 I went into the adegent source code and found where the trouble was. It's on line 99 of "handling.R": kX <- lapply(kX, genind, pop=x at pop, prevcall=prevcall) To preserve ploidy, I think this line should be: kX <- lapply(kX, genind, pop=x at pop, prevcall=prevcall, ploidy = x at ploidy) Can this be implemented in the next version of adegenet? Thanks, Zhian N. Kamvar From t.jombart at imperial.ac.uk Fri Jun 28 14:07:37 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Fri, 28 Jun 2013 12:07:37 +0000 Subject: [adegenet-forum] seploc resets ploidy information to diploid In-Reply-To: <2CB2DA8E426F3541AB1907F98ABA65706387EE7C@icexch-m1.ic.ac.uk> References: , <2CB2DA8E426F3541AB1907F98ABA65706387EE7C@icexch-m1.ic.ac.uk> Message-ID: <2CB2DA8E426F3541AB1907F98ABA65706387EF53@icexch-m1.ic.ac.uk> Hi all, Here is a patch fixing the issue spotted by Zhian, as well as another related bug in seploc. Cheers Thibaut ________________________________________ From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Jombart, Thibaut [t.jombart at imperial.ac.uk] Sent: 28 June 2013 11:26 To: Zhian Kamvar; adegenet-forum at lists.r-forge.r-project.org Subject: Re: [adegenet-forum] seploc resets ploidy information to diploid Dear Zhian, many thanks for spotting this! I'll make the change straight away, and the next release of adegenet will incorporate it. Meanwhile, the fixed devel version will be available from sourceforge: https://sourceforge.net/projects/adegenet/?source=directory Best Thibaut ________________________________________ From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Zhian Kamvar [zkamvar at gmail.com] Sent: 26 June 2013 23:05 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] seploc resets ploidy information to diploid Hello, I was working on some analyses dealing with polyploids, and I noticed that seploc resets the ploidy information of each locus to diploid, regardless of initial ploidy. For a simplified example, here's your example from the adegenet-basics.pdf: > temp <- lapply(1:30, function(i) sample(1:9, 4, replace=TRUE)) > temp <- sapply(temp, paste, collapse="") > temp <- matrix(temp, nrow=10, dimnames=list(paste("ind",1:10), paste("loc",1:3))) > obj <- df2genind(temp, ploidy=4, sep="") > objloc <- seploc(obj) > sapply(objloc, ploidy) loc 1 loc 2 loc 3 2 2 2 > ploidy(obj) [1] 4 I went into the adegent source code and found where the trouble was. It's on line 99 of "handling.R": kX <- lapply(kX, genind, pop=x at pop, prevcall=prevcall) To preserve ploidy, I think this line should be: kX <- lapply(kX, genind, pop=x at pop, prevcall=prevcall, ploidy = x at ploidy) Can this be implemented in the next version of adegenet? Thanks, Zhian N. Kamvar _______________________________________________ adegenet-forum mailing list adegenet-forum at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum -------------- next part -------------- A non-text attachment was scrubbed... Name: handling.R Type: application/octet-stream Size: 17769 bytes Desc: handling.R URL: