[adegenet-forum] adegenet - a.score.opt vs. xvalDAPC

Thibaut Jombart thibautjombart at gmail.com
Wed Jun 14 13:47:32 CEST 2017


Hi again,

OK, so it looks like there was a problem with C routine registration,
following some new policies enforced by CRAN, which could have created
issue with genlight objects. Not related to your problem, but
basically you wouldn't have been able to use genlight objects in the
first place. This is fixed in the devel now.

As for youR problem, after installing the devel version of adegenet,
things should work simply with 'tab'. Here's a toy example:

>  dat <- lapply(1:50, function(i) sample(c(0,1,NA), 1e3, prob=c(.5, .49, .01), replace=TRUE))
>  x <- new("genlight", dat, pop = rep(1:2, each = 25))
> x
 /// GENLIGHT OBJECT /////////

 // 50 genotypes,  1,000 binary SNPs, size: 76.5 Kb
 530 (1.06 %) missing data

 // Basic content
   @gen: list of 50 SNPbin

 // Optional content
   @pop: population of each individual (group size range: 25-25)
   @other: a list containing: elements without names

> X <- tab(x, NA.method = "mean")
> xval1 <- xvalDapc(X, grp = pop(x))


Best
Thibaut

--
Dr Thibaut Jombart
Lecturer, Department of Infectious Disease Epidemiology, Imperial College London
Head of RECON: repidemicsconsortium.org
WHO Consultant - outbreak analysis
sites.google.com/site/thibautjombart/
Twitter: @TeebzR
+44(0)20 7594 3658


On 14 June 2017 at 12:15, Thibaut Jombart <thibautjombart at gmail.com> wrote:
> Hello,
>
> this should work with the devel version using 'tab' on the genlight
> object, but I have just seen an issue accessing C functions underlying
> genlight on most recent R. Investigating. Will post back soon.
>
> Best
> Thibaut
>
> --
> Dr Thibaut Jombart
> Lecturer, Department of Infectious Disease Epidemiology, Imperial College London
> Head of RECON: repidemicsconsortium.org
> WHO Consultant - outbreak analysis
> sites.google.com/site/thibautjombart/
> Twitter: @TeebzR
> +44(0)20 7594 3658
>
>
> On 13 June 2017 at 02:41, Crawford, Douglas L <dcrawford at rsmas.miami.edu> wrote:
>> Good Afternoon,
>>     I cannot get results from “xialdapc”.   I apologize for the long list of
>> attempts.
>> In general,    I have followed the advice in the "A tutorial for
>> Discriminant Analysis of Principal Components (DAPC) using adegenet 2.0.0”,
>> "https://grunwaldlab.github.io/Population_Genetics_in_R/DAPC.html” and
>> thibautjombart commented on May 9 • edited  about Replace NA in genlight
>> file for xvalDapc #168
>>
>> Mydata;
>> Using penlight object:
>> /// GENLIGHT OBJECT /////////
>>
>>  // 69 genotypes,  3,243 binary SNPs, size: 487.6 Kb
>>  32430 (14.49 %) missing data
>>
>>  // Basic content
>>    @gen: list of 69 SNPbin
>>    @ploidy: ploidy of each individual  (range: 2-2)
>>
>>  // Optional content
>>    @ind.names:  69 individual labels
>>    @loc.names:  3243 locus labels
>>    @pop: population of each individual (group size range: 4-22)
>>    @other: a list containing: sex  phenotype  pat  mat
>>
>> COMMANDS & ERRORS:
>> cmd:
>> xval1 <- xvalDapc(CR_grp, grp, n.pca.max = 65, training.set = 0.9, result =
>> "groupMean", center = TRUE, scale = FALSE, n.pca = NULL, n.rep = 30,
>> xval.plot = TRUE)
>>
>> #error
>> Error in sort.list(y) : 'x' must be atomic for 'sort.list'
>> Have you called 'sort' on a list
>>
>> cmd:
>> grp <- pop(CR_grp)
>> cmd:
>> xval1 <- xvalDapc(dapcCRg, grp, n.pca.max = 65, training.set = 0.9, result =
>> "groupMean", center = TRUE, scale = FALSE, n.pca = NULL, n.rep = 30,
>> xval.plot = TRUE)
>> #error
>> Error in as.data.frame.default(df) : cannot coerce class ""dapc"" to a
>> data.frame
>>
>> Following DAPC tutorial 2.0.0
>> Cmd:
>> mat <- as.matrix(na.replace(CR_grp, method="mean"))
>> # error
>> Error in as.matrix(na.replace(CR_grp, method = "mean")) :
>>   error in evaluating the argument 'x' in selecting a method for function
>> 'as.matrix': Error: could not find function "na.replace"
>>
>> Following thibautjombart commented on May 9
>>
>> Cmd:
>> mat <- as.matrix(CR_grp, NA.method = "mean")
>> #ok
>> Cmd:
>> grp <- pop(CR_grp)
>> #ok
>>
>> Cmd:
>> xvalg <- xvalDapc(mat, grp, n.pca.max = 300, training.set = 0.9,
>>                  result = "groupMean", center = TRUE, scale = FALSE,
>>                  n.pca = NULL, n.rep = 30, xval.plot = TRUE)
>> error:
>> Error in dudi.pca(x, nf = n.pca.max, scannf = FALSE, center = center,  :
>>   na entries in table
>>
>>
>> Following https://grunwaldlab.github.io/Population_Genetics_in_R/DAPC.html
>>
>> CRgrpx <- xvalDapc(tab(CR_grp, NA.method = "mean"), pop(CR_grp))
>> #Error in (function (classes, fdef, mtable) : unable to find an inherited
>> method for function ‘tab’ for signature ‘"genlight"’
>> CRgrpx <- xvalDapc(CR_grp, pop(CR_grp))
>> #Error in dudi.pca(x, nf = n.pca.max, scannf = FALSE, center = center,: na
>> entries in table
>>
>> Any suggestions would be appreciated.
>>
>> Douglas
>>
>>
>> ——************________*********————
>> Douglas L. Crawford
>> Professor, Marine Biology & Ecology
>> Rosenstiel School of Marine & Atmospheric Science
>> University of Miami
>> 4600 Rickenbacker Causeway
>> Mami, FL 33149
>> 305-421-4121
>>
>> dcrawford at miami.edu
>> http://www.funhe-evol.org/
>>
>>
>>
>> _______________________________________________
>> 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


More information about the adegenet-forum mailing list