[adegenet-forum] Cross validation using xvalDapc
Kirsty Medcalf
kirsty.m.medcalf at gmail.com
Tue Sep 29 18:44:08 CEST 2015
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. this is an updated version of a previous post after
taking into account the recommendationsbut I am still outputting the same
error message. Do I have to change my data frame into a list? If so, what
would be the correct format to transform the data frame into this format.
If this is possible, I was wondering if anyone had a solution with how to
solve this error message (below). I have looked online and through
available tutorials and still cannot solve this issue. Words cannot
describe my gratitude if this is possible.
#Permute the data
set.seed(999)
x<-LDA.scores[,2:13]
grp1<-find.clusters(x, max.n.clust=12)
dapc1<-dapc(x, grp1$grp)
#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
#Loadings plot
contrib <- loadingplot(dapc1$var.contr, axis=2,
thres=.07, lab.jitter=1)
#Cross Validation
windows(width=10, height=7)
set.seed(1234)
x1 <- LDA.scores
str(x1)
x1$Matriline<-as.factor(x1$Matriline)
xval <- xvalDapc(x1, grp1, n.pca.max = 2, 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?
During the DAPC analysis, I chose to retain 2 PCs and 2 LD's, and there
appears to be 3 clusters. Would n.pca.max=2 be correct?
My reproducible data, the logical steps that I took to chose the number of
PC's and LD's to retain, and the number of chosen clusters is available on
stack overflow
http://stackoverflow.com/questions/32704902/discriminant-analysis-of-principal-components-and-how-to-graphically-show-the-di
If it is possible to help me, then thank you
Best wishes,
Kirsty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150929/267ebe23/attachment-0001.html>
More information about the adegenet-forum
mailing list