[adegenet-forum] Cross validation using xvalDapc

Jombart, Thibaut t.jombart at imperial.ac.uk
Mon Sep 28 13:18:21 CEST 2015


Hi Kirsty,

if you have N individuals and P variables, the maximum number of PCs of a PCA is at most min(N,P): in your case, you cannot have more than 12 PCs associated to non-null eigenvalues.

Otherwise, regarding the quoted code, I don't know what this is:
mat <- as.matrix(x1, method="mean")

Also grp2 does not look like a factor at all to me.

The input for xvalDapc should mimic the input of a dapc. Please check the examples.

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 Roman Lustrik [roman.lustrik at biolitika.si]
Sent: 28 September 2015 08:38
To: Kirsty Medcalf
Cc: adegenet-forum at lists.r-forge.r-project.org
Subject: Re: [adegenet-forum] Cross validation using xvalDapc

Hi,

can you make your example reproducible (simulate some data)?

As for the n.pca.max argument. PCA is a dimension reduction technique. Which means it tries to present data of N variables (columns) as as few principal components as possible. If you think of a 3D cloud shaped like a sphere (3 variables describe this, call them x, y and z), PCA will try to show you the data in 2D (two principal components, call them PC1 and PC2). What you expect to see is a circle which explains most of the variation, since circle is quite good approximation of a sphere. If you add data from PC3, you get a sphere again (and all variation explained).

Retaining all components is not practical so the function will retain only `n.pca.max` components.

Cheers,
Roman

----
In god we trust, all others bring data.

________________________________
From: "Kirsty Medcalf" <kirsty.m.medcalf at gmail.com>
To: adegenet-forum at lists.r-forge.r-project.org
Sent: Monday, September 28, 2015 4:44:06 AM
Subject: [adegenet-forum] Cross validation using xvalDapc

Hi

I am attempting to cross validate my results from DAPC analysis with a 70 % training set using the function xvalDapc (code below).  My data frame is called LDA.scores. If this is possible, I was wondering if anyone had a solution to this error message (below).  I have looked online and through available tutorials and still cannot
solve this issue.

Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

 Also, I have confusion regarding the argument n.pca.max.  My data frame has two grouping dependent factors, 12 predictor values and 80 observations.  Would n.pca.max=80 be correct?

If it is possible to help me, then thank you

Best wishes,
Kirsty

CODE

#Permute the data
set.seed(999)

#DAPC analysis

windows(width=10, height=7)
x<-LDA.scores[,2:13]
grp1<-find.clusters(x, max.n.clust=12)
dapc1<-dapc(x, grp1$grp)
dapc1

windows(width=10, height=7)
x1 <- LDA.scores
mat <- as.matrix(x1, method="mean")
grp2 <- x1
xval <- xvalDapc(mat, grp2, n.pca.max = 80, training.set = 0.7,
                 result = "groupMean", center = TRUE, scale = FALSE,
                 n.pca = NULL, n.rep = 30, xval.plot = TRUE)


Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?


Kirsty Medcalf

kirsty.m.medcalf at gmail.com<mailto:kirsty.m.medcalf at gmail.com>

+447963374030<tel:%2B447963374030>

skype contact: kirsty.medcalf

_______________________________________________
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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150928/34a41f0b/attachment.html>


More information about the adegenet-forum mailing list