[adegenet-forum] Error in `row.names<-.data.frame`

Martin van der Meer martinhvandermeer at gmail.com
Tue Sep 20 00:44:16 CEST 2011


Hi All

Further to this post, i tried giving all the individuals in the dataset a
unique value before
importing as a geniod object in R, i then used the same code as below.
 This still had the same effect at the end:

> m.dapc <- dapc(m.pca, grp=pop(M))
Choose the number PCs to retain (>=1): 23
Error in `row.names<-.data.frame`(`*tmp*`, value = c("Axis1", "Axis2", :
invalid 'row.names' length
I tired on a friends Mac OS computer last night with the latest version of
all packages
installed from CRAN and it still didnt work? This code worked in the past on
older versions
of R and adegenet, im wondering if this is where the issue might lie?

Has anyone tried running an (unedited)  Genpop file with the below commands
in the new versions, im
interested to see if they can reproduce the errors i have.

cheers
Martin


Martin van der Meer
PhD candidate
Molecular Ecology and Evolutionary Laboratory
Australian Tropical Sciences and Innovation Precinct
School of Marine and Tropical Biology
James Cook University
Townsville
Australia


On 19 September 2011 13:25, Martin van der Meer <martinhvandermeer at gmail.com
> wrote:

> Hi All
>
> Ive had to switch to a PC (Windows Vista) since the Mac OS system crashed.
> Ive installed R with all
> the packages for running DAPC (ade4, Adegenet, MASS). I use the same
> command codes that i
> used for R in the Mac OS. I have not changed the directories from where R
> was loaded and
> all packages and R are the latest version. My file format is in Genepop. I
> have tried a vraiety of
> methods including importing as a table and using read.table, giving
> individual numbers in the genepop file,
>  i have run R as an administrator, etc all to no avail. This is incredibely
> frustrating as it works without flaw
> in the Mac OS. Any help would be appreciated. Here is the code im using for
> R:
>
>
>
> > read.genepop("Aa.gen") -> M
>  Converting data from a Genepop .gen file to a genind object...
>
> File description:  Title line:"Aa"
> ...done.
> > M1 <- scaleGen(M, missing="mean")
> Pop1 Pop2 Pop3 Pop4 Pop5
>   14   20   24   28   33
> Warning message:
> In validityMethod(object) :
> duplicate names in ind.names:
> > m.pca <- dudi.pca(M1, center=FALSE, scale=FALSE, scannf=FALSE, nf=100)
> Error in `row.names<-.data.frame`(`*tmp*`, value = c("Pop1", "Pop1",
> "Pop1",  :
>   duplicate 'row.names' are not allowed
> In addition: Warning message:
> non-unique values when setting 'row.names': ‘Pop1’, ‘Pop2’, ‘Pop3’, ‘Pop4’,
> ‘Pop5’
> > uniquewt.df(M1)-> M2
> Warning message:
> In data.row.names(row.names, rowsi, i) :
>   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
> > m.pca <- dudi.pca(M2, center=FALSE, scale=FALSE, scannf=FALSE, nf=100)
> > barplot(m.pca$eig, main="eigen")
> > temp <- cumsum(m.pca$eig)/sum(m.pca$eig)
> > plot(temp, xlab="addedpc", ylab="totgenet")
> > min(which(temp > 0.95))
> [1] 92
> > axis(1, at = 92, lab = 92)
> > segments(92, 0, 92, temp[92], col = "red")
> > segments(-5, 0.95, 92, 0.95, col = "red")
> > s.class(m.pca$li, M$pop, lab= M$pop.names, sub="PCA 1-2", csub= 2)
> > add.scatter.eig(m.pca$eig[1:20], nf = 3, xax = 1, yax = 2, posi =
> "bottom")
> > m.lda <- lda(m.pca$li[, 1:92], grouping=pop(M))
> > names(m.lda)
> [1] "prior"   "counts"  "means"   "scaling" "lev"     "svd"     "N"
> "call"
> > m.pred <- predict(m.lda)
> > m.pred$class
>   [1] Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1 Pop1
> Pop2 Pop2 Pop2 Pop2 Pop2
>  [20] Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2 Pop2
> Pop2 Pop3 Pop3 Pop3 Pop3
>  [39] Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3 Pop3
> Pop3 Pop3 Pop3 Pop3 Pop3
>  [58] Pop3 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4
> Pop4 Pop4 Pop4 Pop4 Pop4
>  [77] Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop4 Pop5 Pop5 Pop5 Pop5
> Pop5 Pop5 Pop5 Pop5 Pop5
>  [96] Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5 Pop5
> Pop5 Pop5 Pop5 Pop5 Pop5
> [115] Pop5 Pop5 Pop5 Pop5 Pop5
> Levels: Pop1 Pop2 Pop3 Pop4 Pop5
> > head(m.pred$posterior[, 1:5])
>   Pop1         Pop2         Pop3         Pop4         Pop5
> 1    1 4.177827e-31 1.917492e-27 1.506373e-34 7.272060e-35
> 2    1 4.848692e-28 9.903303e-25 2.649258e-33 4.010207e-35
> 3    1 4.937353e-20 5.195535e-16 1.195006e-19 2.183740e-24
> 4    1 4.608358e-19 1.503307e-15 7.937646e-22 5.661887e-24
> 5    1 1.225733e-27 2.661842e-20 6.963585e-34 2.458251e-36
> 6    1 3.344632e-15 2.383149e-18 1.608183e-26 7.585079e-31
> > mean(m.pred$class==pop(M))
> [1] 1
> > misAs <-tapply(m.pred$class !=pop(M), pop(M), mean)
> > barplot(misAs, xlab="populations", ylab= "% of missassignments per pop",
> col="orange", las=3)
> > table.paint(head(m.pred$posterior, 119, col.lab= paste("population", 1:5,
> sep=".")))
> > m.dapc <- dapc(m.pca, grp=pop(M))
> Choose the number PCs to retain (>=1): 23
> Error in `row.names<-.data.frame`(`*tmp*`, value = c("Axis1", "Axis2",  :
>   invalid 'row.names' length
>
>
> --
> Martin van der Meer
> PhD candidate
> Molecular Ecology and Evolutionary Laboratory
> Australian Tropical Sciences and Innovation Precinct
> School of Marine and Tropical Biology
> James Cook University
> Townsville
> Australia
>
>


-- 
Martin van der Meer
PhD candidate
Molecular Ecology and Evolutionary Laboratory
Australian Tropical Sciences and Innovation Precinct
School of Marine and Tropical Biology
James Cook University
Townsville
Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20110920/72b19eac/attachment-0001.htm>


More information about the adegenet-forum mailing list