<div>Hi Thibaut</div><div> </div><div>Thanks, that sorted out the probelm straight away.</div><div> </div><div>cheers</div><div>Martin<br><br></div><div class="gmail_quote">On 20 September 2011 09:15, Jombart, Thibaut <span dir="ltr"><<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>></span> wrote:<br>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote">Hello,<br>
<br>
if "m.pca" is a dudi.pca object (that is, a list), this instruction should not work. I assume "M" is your genind object with a relevant clustering information returned by "pop(M)". Can you try:<br>
<br>
####<br>
m.dapc <- dapc(M, grp=pop(M))<br>
####<br>
?<br>
<br>
Cheers<br>
<br>
Thibaut<br>
________________________________________<br>
From: <a href="mailto:adegenet-forum-bounces@r-forge.wu-wien.ac.at">adegenet-forum-bounces@r-forge.wu-wien.ac.at</a> [<a href="mailto:adegenet-forum-bounces@r-forge.wu-wien.ac.at">adegenet-forum-bounces@r-forge.wu-wien.ac.at</a>] on behalf of Martin van der Meer [<a href="mailto:martinhvandermeer@gmail.com">martinhvandermeer@gmail.com</a>]<br>
Sent: 19 September 2011 23:44<br>
To: <a href="mailto:adegenet-forum@r-forge.wu-wien.ac.at">adegenet-forum@r-forge.wu-wien.ac.at</a><br>
Subject: Re: [adegenet-forum] Error in `row.names<-.data.frame`<br>
<div class="im"><br>
Hi All<br>
<br>
Further to this post, i tried giving all the individuals in the dataset a unique value before<br>
importing as a geniod object in R, i then used the same code as below.<br>
This still had the same effect at the end:<br>
<br>
> m.dapc <- dapc(m.pca, grp=pop(M))<br>
Choose the number PCs to retain (>=1): 23<br>
Error in `row.names<-.data.frame`(`*tmp*`, value = c("Axis1", "Axis2", :<br>
invalid 'row.names' length<br>
I tired on a friends Mac OS computer last night with the latest version of all packages<br>
installed from CRAN and it still didnt work? This code worked in the past on older versions<br>
of R and adegenet, im wondering if this is where the issue might lie?<br>
<br>
Has anyone tried running an (unedited) Genpop file with the below commands in the new versions, im<br>
interested to see if they can reproduce the errors i have.<br>
<br>
cheers<br>
Martin<br>
<br>
<br>
Martin van der Meer<br>
PhD candidate<br>
Molecular Ecology and Evolutionary Laboratory<br>
Australian Tropical Sciences and Innovation Precinct<br>
School of Marine and Tropical Biology<br>
James Cook University<br>
Townsville<br>
Australia<br>
<br>
<br>
</div><div><div></div><div class="h5">On 19 September 2011 13:25, Martin van der Meer <<a href="mailto:martinhvandermeer@gmail.com">martinhvandermeer@gmail.com</a><mailto:<a href="mailto:martinhvandermeer@gmail.com">martinhvandermeer@gmail.com</a>>> wrote:<br>
Hi All<br>
<br>
Ive had to switch to a PC (Windows Vista) since the Mac OS system crashed. Ive installed R with all<br>
the packages for running DAPC (ade4, Adegenet, MASS). I use the same command codes that i<br>
used for R in the Mac OS. I have not changed the directories from where R was loaded and<br>
all packages and R are the latest version. My file format is in Genepop. I have tried a vraiety of<br>
methods including importing as a table and using read.table, giving individual numbers in the genepop file,<br>
i have run R as an administrator, etc all to no avail. This is incredibely frustrating as it works without flaw<br>
in the Mac OS. Any help would be appreciated. Here is the code im using for R:<br>
<br>
<br>
<br>
> read.genepop("Aa.gen") -> M<br>
Converting data from a Genepop .gen file to a genind object...<br>
<br>
File description: Title line:"Aa"<br>
...done.<br>
> M1 <- scaleGen(M, missing="mean")<br>
Pop1 Pop2 Pop3 Pop4 Pop5<br>
14 20 24 28 33<br>
Warning message:<br>
In validityMethod(object) :<br>
duplicate names in ind.names:<br>
> m.pca <- dudi.pca(M1, center=FALSE, scale=FALSE, scannf=FALSE, nf=100)<br>
Error in `row.names<-.data.frame`(`*tmp*`, value = c("Pop1", "Pop1", "Pop1", :<br>
duplicate 'row.names' are not allowed<br>
In addition: Warning message:<br>
non-unique values when setting 'row.names': ‘Pop1’, ‘Pop2’, ‘Pop3’, ‘Pop4’, ‘Pop5’<br>
> uniquewt.df(M1)-> M2<br>
Warning message:<br>
In data.row.names(row.names, rowsi, i) :<br>
some row.names duplicated: 2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119 --> row.names NOT used<br>
> m.pca <- dudi.pca(M2, center=FALSE, scale=FALSE, scannf=FALSE, nf=100)<br>
> barplot(m.pca$eig, main="eigen")<br>
> temp <- cumsum(m.pca$eig)/sum(m.pca$eig)<br>
> plot(temp, xlab="addedpc", ylab="totgenet")<br>
> min(which(temp > 0.95))<br>
[1] 92<br>
> axis(1, at = 92, lab = 92)<br>
> segments(92, 0, 92, temp[92], col = "red")<br>
> segments(-5, 0.95, 92, 0.95, col = "red")<br>
> s.class(m.pca$li, M$pop, lab= M$pop.names, sub="PCA 1-2", csub= 2)<br>
> add.scatter.eig(m.pca$eig[1:20], nf = 3, xax = 1, yax = 2, posi = "bottom")<br>
> m.lda <- lda(m.pca$li[, 1:92], grouping=pop(M))<br>
> names(m.lda)<br>
[1] "prior" "counts" "means" "scaling" "lev" "svd" "N" "call"<br>
> m.pred <- predict(m.lda)<br>
> m.pred$class<br>
[1] Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop2 Pop2 Pop2 Pop2 Pop2<br>
[20] Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop3 Pop3 Pop3 Pop3<br>
[39] Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3<br>
[58] Pop3 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4<br>
[77] Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5<br>
[96] Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5<br>
[115] Pop5 Pop5 Pop5 Pop5 Pop5<br>
Levels: Pop1 Pop2 Pop3 Pop4 Pop5<br>
> head(m.pred$posterior[, 1:5])<br>
Pop1 Pop2 Pop3 Pop4 Pop5<br>
1 1 4.177827e-31 1.917492e-27 1.506373e-34 7.272060e-35<br>
2 1 4.848692e-28 9.903303e-25 2.649258e-33 4.010207e-35<br>
3 1 4.937353e-20 5.195535e-16 1.195006e-19 2.183740e-24<br>
4 1 4.608358e-19 1.503307e-15 7.937646e-22 5.661887e-24<br>
5 1 1.225733e-27 2.661842e-20 6.963585e-34 2.458251e-36<br>
6 1 3.344632e-15 2.383149e-18 1.608183e-26 7.585079e-31<br>
> mean(m.pred$class==pop(M))<br>
[1] 1<br>
> misAs <-tapply(m.pred$class !=pop(M), pop(M), mean)<br>
> barplot(misAs, xlab="populations", ylab= "% of missassignments per pop", col="orange", las=3)<br>
> table.paint(head(m.pred$posterior, 119, col.lab= paste("population", 1:5, sep=".")))<br>
> m.dapc <- dapc(m.pca, grp=pop(M))<br>
Choose the number PCs to retain (>=1): 23<br>
Error in `row.names<-.data.frame`(`*tmp*`, value = c("Axis1", "Axis2", :<br>
invalid 'row.names' length<br>
<br>
<br>
--<br>
Martin van der Meer<br>
PhD candidate<br>
Molecular Ecology and Evolutionary Laboratory<br>
Australian Tropical Sciences and Innovation Precinct<br>
School of Marine and Tropical Biology<br>
James Cook University<br>
Townsville<br>
Australia<br>
<br>
<br>
<br>
<br>
--<br>
Martin van der Meer<br>
PhD candidate<br>
Molecular Ecology and Evolutionary Laboratory<br>
Australian Tropical Sciences and Innovation Precinct<br>
School of Marine and Tropical Biology<br>
James Cook University<br>
Townsville<br>
Australia<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>Martin van der Meer<br>PhD candidate<br>Molecular Ecology and Evolutionary Laboratory<br>Australian Tropical Sciences and Innovation Precinct</div>
<div>School of Marine and Tropical Biology<br>James Cook University<br>Townsville<br>Australia</div><br>