[adegenet-forum] sPCA with adegenet

tyfanie bourlet tyfanie.bourlet at florimond-desprez.fr
Fri Jul 19 13:48:08 CEST 2013


Dear Dr Jombart,

Thank you very much for answering me so fast.
Please find attached a part of my data set in csv file :
marker

sbPb-3066557

sbPb-3066720

sbPb-3066853

Beta patula

0

1

1

Beta patula

0

1

1

Beta macrocarpa

1

1

0

Beta macrocarpa

1

1

0

Beta macrocarpa

1

1

0

Beta macrocarpa

1

1

0

Beta macrocarpa

0

1

1

Beta macrocarpa

1

1

0

Beta macrocarpa

1

1

0

Beta macrocarpa

1

1

0

Beta macrocarpa

1

1

NA


I didn't know how to add the geographical data, so I put them in a second sheet :
x

y

33.3333

34.7333

33.6167

34.8

27.202148

35.532226

27.202148

35.532226

19.599609

47.115

34.4667

31.4167

34.4667

31.4167

-7.76667

37.0667






The name of my data set in R is : "test". So I first try to convert my data set into genind object with this script of genind constructor :
test <-
  read.table("//Serveur/m/13 - STAGIAIRES BETTERAVES/2012_tyfanie BOURLET/AKER/sPCA/testspca.txt",
   header=TRUE, sep="", na.strings="NA", dec=".", strip.white=TRUE)
test <- sqlQuery(channel = 3, select * from [test sPCA$])
names(test) <- make.names(names(test))
x <- as.matrix(test)
genind(test,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA"))
as.genind(test,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA"))
is.genind(test)

And R put me this :

> test <-
+   read.table("//Serveur/m/13 - STAGIAIRES BETTERAVES/2012_tyfanie BOURLET/AKER/sPCA/testspca.txt",
+    header=TRUE, sep="", na.strings="NA", dec=".", strip.white=TRUE)

> test <- sqlQuery(channel = 3, select * from [test sPCA$])

> names(test) <- make.names(names(test))

> x <- as.matrix(test)

> genind(test,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA"))

   #####################
   ### Genind object ###
   #####################
- genotypes of individuals -

S4 class:  genind
@call: genind(tab = test, pop = NULL, prevcall = NULL, ploidy = 2, type = c("codom",
    "PA"))

@tab:  1114 x 255 matrix of genotypes

@ind.names: vector of  1114 individual names
@loc.names: vector of  2 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  255 columns of @tab
@all.names: list of  2 components yielding allele names for each locus
@ploidy:  2
@type:  codom

Optionnal contents:
@pop:  - empty -
@pop.names:  - empty -

@other: - empty -


> as.genind(test,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA"))

   #####################
   ### Genind object ###
   #####################
- genotypes of individuals -

S4 class:  genind
@call: as.genind(tab = test, pop = NULL, prevcall = NULL, ploidy = 2,
    type = c("codom", "PA"))

@tab:  1114 x 255 matrix of genotypes

@ind.names: vector of  1114 individual names
@loc.names: vector of  2 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the  255 columns of @tab
@all.names: list of  2 components yielding allele names for each locus
@ploidy:  2
@type:  codom

Optionnal contents:
@pop:  - empty -
@pop.names:  - empty -

@other: - empty -


> is.genind(test)
[1] FALSE

So apparently R doesn't consider that my data set is a genind object...
And then when I want to start the sPCA analysis I enter this script :

library(adegenet)
library(adehabitat)
data(test)
obj <- test$dat2A
obj
test <- test$dat2A
test
head(truenames(obj[loc="sbPb"])$tab)

And R put me this :
 WARNING: Warning in data(test) : data set 'test' not found
ERROR:
error in evaluating the argument 'x' in selecting a method for function 'truenames'

And I have another problem. When I import my data set in csv format, R take only the 255 first columns (I have 4630 columns) so I have to import my data in text format but then, R give me this error message : "[10] ERROR: line 16 did not have 4631 elements" whereas all my lines have 4630 elements...

Thanking you in advance for helping me. I'm not an expert at all with R but it would be very helpful if I can manage this sPCA.
Best regards,

Tyfanie Bourlet
France
Florimond Desprez
Beet laboratory
Student at Agrocampus Ouest
0672610237

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


More information about the adegenet-forum mailing list