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

Crawford, Douglas L dcrawford at rsmas.miami.edu
Wed Jun 14 14:27:14 CEST 2017


Thank you.

I have said it before and will say it again:  your efforts are very much appreciated by many.

dlc


On Jun 14, 2017, at 7:47 AM, Thibaut Jombart <thibautjombart at gmail.com<mailto:thibautjombart at gmail.com>> wrote:

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<http://repidemicsconsortium.org>
WHO Consultant - outbreak analysis
sites.google.com/site/thibautjombart/<http://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://urldefense.proofpoint.com/v2/url?u=https-3A__grunwaldlab.github.io_Population-5FGenetics-5Fin-5FR_DAPC.html&d=DwIFaQ&c=y2w-uYmhgFWijp_IQN0DhA&r=BpG6K2k1Rl1JP8zpH3Kivhq29ZS4KUsaaEDq0PE3O4A&m=xWOBcPJ7sxqTwQME6kgKFJbsiua_iZdhojC_48YZSgY&s=dOvQ0Yp8vrw_M9sTQ29-UpiUtWKZc6K-TIcjx9A_45Y&e= ” 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://urldefense.proofpoint.com/v2/url?u=https-3A__grunwaldlab.github.io_Population-5FGenetics-5Fin-5FR_DAPC.html&d=DwIFaQ&c=y2w-uYmhgFWijp_IQN0DhA&r=BpG6K2k1Rl1JP8zpH3Kivhq29ZS4KUsaaEDq0PE3O4A&m=xWOBcPJ7sxqTwQME6kgKFJbsiua_iZdhojC_48YZSgY&s=dOvQ0Yp8vrw_M9sTQ29-UpiUtWKZc6K-TIcjx9A_45Y&e=

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
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.funhe-2Devol.org_&d=DwIFaQ&c=y2w-uYmhgFWijp_IQN0DhA&r=BpG6K2k1Rl1JP8zpH3Kivhq29ZS4KUsaaEDq0PE3O4A&m=xWOBcPJ7sxqTwQME6kgKFJbsiua_iZdhojC_48YZSgY&s=3diONTc_po7Rti6_N2AMH7EI6XBXjunupS_xKoA3s6U&e=



_______________________________________________
adegenet-forum mailing list
adegenet-forum at lists.r-forge.r-project.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.r-2Dforge.r-2Dproject.org_cgi-2Dbin_mailman_listinfo_adegenet-2Dforum&d=DwIFaQ&c=y2w-uYmhgFWijp_IQN0DhA&r=BpG6K2k1Rl1JP8zpH3Kivhq29ZS4KUsaaEDq0PE3O4A&m=xWOBcPJ7sxqTwQME6kgKFJbsiua_iZdhojC_48YZSgY&s=Zb2bb0LD_77THMZ35JjMhQFqNbBXN-KrZV_4J0I4zt0&e=

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20170614/05115be2/attachment-0001.html>


More information about the adegenet-forum mailing list