From SotkaE at cofc.edu Mon Jul 15 05:04:53 2013 From: SotkaE at cofc.edu (Sotka, Erik) Date: Mon, 15 Jul 2013 03:04:53 +0000 Subject: [adegenet-forum] Analyzing a genetic distance matrix in DAPC Message-ID: <4B2F644F-8075-4CD5-8E47-F8CF25D9C12C@cofc.edu> Hello! I would like to know if it were possible to enter a genetic distance matrix into the DAPC analysis. The matrix contains Bruvo distances, useful for a species with mixed ploidy in the same population. All of the tutorials and examples I can find enter raw genetic data into find.clusters() or dapc(). Thank you! Erik -- Erik Sotka Associate Professor of Biology, College of Charleston Grice Marine Laboratory, 205 Fort Johnson Road, Charleston, SC 29412 Office: 843-953-9191 eMail: SotkaE at cofc.edu www.MarineEvolutionaryEcology.org From t.jombart at imperial.ac.uk Tue Jul 16 22:59:22 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Tue, 16 Jul 2013 20:59:22 +0000 Subject: [adegenet-forum] Analyzing a genetic distance matrix in DAPC In-Reply-To: <4B2F644F-8075-4CD5-8E47-F8CF25D9C12C@cofc.edu> References: <4B2F644F-8075-4CD5-8E47-F8CF25D9C12C@cofc.edu> Message-ID: <2CB2DA8E426F3541AB1907F98ABA657063899F26@icexch-m1.ic.ac.uk> Dear Erik, you can't, not directly anyway, but as a trick you can feed dapc the principal components (all of them) of a principal coordinate analysis / MDS. See the function dudi.pco in ade4. Assuming pco1 is the output of dudi.pco on your distance matrix, you want to use the coordinates in pco1$li as input to DAPC. All the best Thibaut -- ###################################### Dr Thibaut JOMBART MRC Centre for Outbreak Analysis and Modelling Department of Infectious Disease Epidemiology Imperial College - School of Public Health St Mary?s Campus Norfolk Place London W2 1PG United Kingdom Tel. : 0044 (0)20 7594 3658 t.jombart at imperial.ac.uk http://sites.google.com/site/thibautjombart/ http://adegenet.r-forge.r-project.org/ ________________________________________ From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Sotka, Erik [SotkaE at cofc.edu] Sent: 15 July 2013 04:04 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] Analyzing a genetic distance matrix in DAPC Hello! I would like to know if it were possible to enter a genetic distance matrix into the DAPC analysis. The matrix contains Bruvo distances, useful for a species with mixed ploidy in the same population. All of the tutorials and examples I can find enter raw genetic data into find.clusters() or dapc(). Thank you! Erik -- Erik Sotka Associate Professor of Biology, College of Charleston Grice Marine Laboratory, 205 Fort Johnson Road, Charleston, SC 29412 Office: 843-953-9191 eMail: SotkaE at cofc.edu www.MarineEvolutionaryEcology.org _______________________________________________ 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 From tyfanie.bourlet at florimond-desprez.fr Fri Jul 19 13:48:08 2013 From: tyfanie.bourlet at florimond-desprez.fr (tyfanie bourlet) Date: Fri, 19 Jul 2013 13:48:08 +0200 Subject: [adegenet-forum] sPCA with adegenet Message-ID: <45F066502200304AADB483BE9ED0DE6F2082D54899@srv-exchg.florimond-desprez.fr> 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: From t.jombart at imperial.ac.uk Fri Jul 19 17:14:21 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Fri, 19 Jul 2013 15:14:21 +0000 Subject: [adegenet-forum] sPCA with adegenet In-Reply-To: <45F066502200304AADB483BE9ED0DE6F2082D54899@srv-exchg.florimond-desprez.fr> References: <45F066502200304AADB483BE9ED0DE6F2082D54899@srv-exchg.florimond-desprez.fr> Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638A7ADC@icexch-m1.ic.ac.uk> Hello, unfortunately there is a number of basic errors here and I can't go through all of them. First, you do not assign the value of 'test' after using the constructor to any object. So 'test' remains unchanged. When calling the constructor, you have to specify type="PA" in your case, and I'm guessing ploidy is 1 too. Then, the call to data(test) does not make sense here. 'data' is used to load data objects distributed with R packages. I am guessing you are reusing code from the sPCA tutorial, but you need to adapt it to your object. As for the read.csv problem, this function is heavily used in R so it is unlikely to be a bug. The best thing to do here is to take a couple of days to get started with R in the first place and going through a basic introduction. A fairly complete one can be found on CRAN: http://cran.r-project.org/doc/manuals/r-release/R-intro.html Without a basic knowledge of R, analyzing your data in R is going to be hellish, and likely prone to unwanted mistakes/errors. Good luck and all the best 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 tyfanie bourlet [tyfanie.bourlet at florimond-desprez.fr] Sent: 19 July 2013 12:48 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] sPCA with adegenet 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 From francesco.montinaro at gmail.com Fri Jul 19 19:22:30 2013 From: francesco.montinaro at gmail.com (Francesco Montinaro) Date: Fri, 19 Jul 2013 18:22:30 +0100 Subject: [adegenet-forum] Find clusters on distance matrix or relative frequency. Message-ID: Hi, I have a matrix very similar to Structure/ADMIXTURE output but produced with a local ancestry algorithm. For example for each population (10 populations) I have how much it "copies" from each of the other populations. Visually,It seems that there are 2 main clusters in composition of each populations, so I would like to cluster them. Unfortunately my matrix is based on relative proportion, and I am afraid that find.cluster function is not suitable because it uses PCA. I was thinking to use the distance matrix of my original data, but I am not sure that it is mathematically correct. In addition I would like to know the right number of cluster, so I cannot use kmeans, not natively at least. Do you have any suggestion? Thank you for your help. Francesco -------------- next part -------------- An HTML attachment was scrubbed... URL: From t.jombart at imperial.ac.uk Fri Jul 19 19:27:29 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Fri, 19 Jul 2013 17:27:29 +0000 Subject: [adegenet-forum] Find clusters on distance matrix or relative frequency. In-Reply-To: References: Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638A7B6C@icexch-m1.ic.ac.uk> Hello, this is not a problem. You can run find.clusters on your composition profiles, just retain all PCs during the PCA step to ensure that all of your original information is preserved. Alternatives would be using a single hierarchical clustering algorithm on the distance matrix (see the function hclust). Best 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 Francesco Montinaro [francesco.montinaro at gmail.com] Sent: 19 July 2013 18:22 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] Find clusters on distance matrix or relative frequency. Hi, I have a matrix very similar to Structure/ADMIXTURE output but produced with a local ancestry algorithm. For example for each population (10 populations) I have how much it "copies" from each of the other populations. Visually,It seems that there are 2 main clusters in composition of each populations, so I would like to cluster them. Unfortunately my matrix is based on relative proportion, and I am afraid that find.cluster function is not suitable because it uses PCA. I was thinking to use the distance matrix of my original data, but I am not sure that it is mathematically correct. In addition I would like to know the right number of cluster, so I cannot use kmeans, not natively at least. Do you have any suggestion? Thank you for your help. Francesco From tyfanie.bourlet at florimond-desprez.fr Tue Jul 23 11:57:50 2013 From: tyfanie.bourlet at florimond-desprez.fr (tyfanie bourlet) Date: Tue, 23 Jul 2013 11:57:50 +0200 Subject: [adegenet-forum] sPCA with adegenet In-Reply-To: <2CB2DA8E426F3541AB1907F98ABA6570638A8040@icexch-m1.ic.ac.uk> References: <45F066502200304AADB483BE9ED0DE6F2082D54899@srv-exchg.florimond-desprez.fr> <2CB2DA8E426F3541AB1907F98ABA6570638A7ADC@icexch-m1.ic.ac.uk>, <45F066502200304AADB483BE9ED0DE6F2082D5493C@srv-exchg.florimond-desprez.fr> <2CB2DA8E426F3541AB1907F98ABA6570638A8040@icexch-m1.ic.ac.uk> Message-ID: <45F066502200304AADB483BE9ED0DE6F2082D54AE2@srv-exchg.florimond-desprez.fr> Hello, I'm really sorry to bother you again but I tried again this time with R studio (I thought I would be easier) but it doesn't work either... This is the beginning of my script : library(adegenet) library(adehabitat) tab1=read.table("test sPCA.csv", header=T, sep=";") attach(tab1) genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) as.genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) is.genind(tab1) obj <- tab1$dat2A obj And this is the outputs : > library(adegenet) Loading required package: ade4 Attaching package: 'ade4' The following object(s) are masked from 'package:base': within ========================== adegenet 1.3-9 is loaded ========================== - to start, type '?adegenet' - to browse adegenet website, type 'adegenetWeb()' - to post questions/comments: adegenet-forum at lists.r-forge.r-project.org Warning messages: 1: package 'adegenet' was built under R version 2.15.3 2: package 'ade4' was built under R version 2.15.3 3: replacing previous import 'as.igraph' when loading 'ape' 4: replacing previous import 'edges' when loading 'ape' > library(adehabitat) Loading required package: tkrplot Loading required package: tcltk Loading Tcl/Tk interface ... done Loading required package: shapefiles Loading required package: foreign Attaching package: 'shapefiles' The following object(s) are masked from 'package:foreign': read.dbf, write.dbf Be careful: it is now recommended to use the newpackages adehabitatMA, adehabitatLT, adehabitatHR, and adehabitatHS. These 4 packages are intended to become the future of adehabitat. The "classical" version of adehabitat will still be maintained for some time, but no new method will be added to the package. Warning messages: 1: package 'adehabitat' was built under R version 2.15.3 2: package 'tkrplot' was built under R version 2.15.2 3: package 'shapefiles' was built under R version 2.15.3 > tab1=read.table("test sPCA.csv", header=T, sep=";") > attach(tab1) > genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) ##################### ### Genind object ### ##################### - genotypes of individuals - S4 class: genind @call: genind(tab = tab1, pop = NULL, prevcall = NULL, ploidy = 2, type = c("codom", "PA")) @tab: 1114 x 4630 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 4630 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(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) ##################### ### Genind object ### ##################### - genotypes of individuals - S4 class: genind @call: as.genind(tab = tab1, pop = NULL, prevcall = NULL, ploidy = 2, type = c("codom", "PA")) @tab: 1114 x 4630 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 4630 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(tab1) [1] FALSE > obj <- tab1$dat2A > obj NULL I try also with ploidy=1 and Type="PA" but it didn't work and for Type="PA" R told me that : Error: unexpected symbol in:"genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type="PA" as.genind" So I really don't understand why it doesn't work ... I try to continue the analysis but of course R told me that my data set wasn't in genind format.... I join a part of my data set, maybe there is a problem with that... Sorry again for bothering you but I really don't know what's the problem.... Thanking you in advance, Best regards, Tyfanie Bourlet -----Message d'origine----- De?: Jombart, Thibaut [mailto:t.jombart at imperial.ac.uk] Envoy??: lundi 22 juillet 2013 12:10 ??: tyfanie bourlet Objet?: RE: sPCA with adegenet No worries. Sorry about that, I understand getting into R in the first place is a bit scary. I'm biaised of course, I would argue it's a worthwhile investment. Cheers Thibaut ________________________________________ From: tyfanie bourlet [tyfanie.bourlet at florimond-desprez.fr] Sent: 22 July 2013 07:06 To: Jombart, Thibaut Subject: RE: sPCA with adegenet Hello, Thank you very much, I will try to fix it all. Again thank you for the time you spent with me. Best Regards, Tyfanie Bourlet -----Message d'origine----- De : Jombart, Thibaut [mailto:t.jombart at imperial.ac.uk] Envoy? : vendredi 19 juillet 2013 17:14 ? : tyfanie bourlet; adegenet-forum at lists.r-forge.r-project.org Objet : RE: sPCA with adegenet Hello, unfortunately there is a number of basic errors here and I can't go through all of them. First, you do not assign the value of 'test' after using the constructor to any object. So 'test' remains unchanged. When calling the constructor, you have to specify type="PA" in your case, and I'm guessing ploidy is 1 too. Then, the call to data(test) does not make sense here. 'data' is used to load data objects distributed with R packages. I am guessing you are reusing code from the sPCA tutorial, but you need to adapt it to your object. As for the read.csv problem, this function is heavily used in R so it is unlikely to be a bug. The best thing to do here is to take a couple of days to get started with R in the first place and going through a basic introduction. A fairly complete one can be found on CRAN: http://cran.r-project.org/doc/manuals/r-release/R-intro.html Without a basic knowledge of R, analyzing your data in R is going to be hellish, and likely prone to unwanted mistakes/errors. Good luck and all the best 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 tyfanie bourlet [tyfanie.bourlet at florimond-desprez.fr] Sent: 19 July 2013 12:48 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] sPCA with adegenet 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 -------------- A non-text attachment was scrubbed... Name: dataset.csv Type: application/octet-stream Size: 2317 bytes Desc: dataset.csv URL: From t.jombart at imperial.ac.uk Tue Jul 23 15:01:48 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Tue, 23 Jul 2013 13:01:48 +0000 Subject: [adegenet-forum] sPCA with adegenet In-Reply-To: <45F066502200304AADB483BE9ED0DE6F2082D54AE2@srv-exchg.florimond-desprez.fr> References: <45F066502200304AADB483BE9ED0DE6F2082D54899@srv-exchg.florimond-desprez.fr> <2CB2DA8E426F3541AB1907F98ABA6570638A7ADC@icexch-m1.ic.ac.uk>, <45F066502200304AADB483BE9ED0DE6F2082D5493C@srv-exchg.florimond-desprez.fr> <2CB2DA8E426F3541AB1907F98ABA6570638A8040@icexch-m1.ic.ac.uk>, <45F066502200304AADB483BE9ED0DE6F2082D54AE2@srv-exchg.florimond-desprez.fr> Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638A84CC@icexch-m1.ic.ac.uk> Hello, sorry for this is a harsh answer, but you really need to do your homework and know at least some basics of R before asking questions on a specialized forum - or attempting any data analysis, for that matter. This: ## genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) ## Converts your data indeed, but DOES NOT SAVE THE CHANGE IN THE OBJECT. This: ## whateverYouWantToCallYourObject <- genind(tab1, ploidy=2, type="PA")) ## is what you want to use, for diploid, presence/absence data. Going through this document will be useful: http://cran.r-project.org/doc/manuals/r-release/R-intro.html 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 tyfanie bourlet [tyfanie.bourlet at florimond-desprez.fr] Sent: 23 July 2013 10:57 To: adegenet-forum at lists.r-forge.r-project.org Subject: Re: [adegenet-forum] sPCA with adegenet Hello, I'm really sorry to bother you again but I tried again this time with R studio (I thought I would be easier) but it doesn't work either... This is the beginning of my script : library(adegenet) library(adehabitat) tab1=read.table("test sPCA.csv", header=T, sep=";") attach(tab1) genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) as.genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) is.genind(tab1) obj <- tab1$dat2A obj And this is the outputs : > library(adegenet) Loading required package: ade4 Attaching package: 'ade4' The following object(s) are masked from 'package:base': within ========================== adegenet 1.3-9 is loaded ========================== - to start, type '?adegenet' - to browse adegenet website, type 'adegenetWeb()' - to post questions/comments: adegenet-forum at lists.r-forge.r-project.org Warning messages: 1: package 'adegenet' was built under R version 2.15.3 2: package 'ade4' was built under R version 2.15.3 3: replacing previous import 'as.igraph' when loading 'ape' 4: replacing previous import 'edges' when loading 'ape' > library(adehabitat) Loading required package: tkrplot Loading required package: tcltk Loading Tcl/Tk interface ... done Loading required package: shapefiles Loading required package: foreign Attaching package: 'shapefiles' The following object(s) are masked from 'package:foreign': read.dbf, write.dbf Be careful: it is now recommended to use the newpackages adehabitatMA, adehabitatLT, adehabitatHR, and adehabitatHS. These 4 packages are intended to become the future of adehabitat. The "classical" version of adehabitat will still be maintained for some time, but no new method will be added to the package. Warning messages: 1: package 'adehabitat' was built under R version 2.15.3 2: package 'tkrplot' was built under R version 2.15.2 3: package 'shapefiles' was built under R version 2.15.3 > tab1=read.table("test sPCA.csv", header=T, sep=";") > attach(tab1) > genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) ##################### ### Genind object ### ##################### - genotypes of individuals - S4 class: genind @call: genind(tab = tab1, pop = NULL, prevcall = NULL, ploidy = 2, type = c("codom", "PA")) @tab: 1114 x 4630 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 4630 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(tab1,pop=NULL,prevcall=NULL, ploidy=2, type=c("codom","PA")) ##################### ### Genind object ### ##################### - genotypes of individuals - S4 class: genind @call: as.genind(tab = tab1, pop = NULL, prevcall = NULL, ploidy = 2, type = c("codom", "PA")) @tab: 1114 x 4630 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 4630 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(tab1) [1] FALSE > obj <- tab1$dat2A > obj NULL I try also with ploidy=1 and Type="PA" but it didn't work and for Type="PA" R told me that : Error: unexpected symbol in:"genind(tab1,pop=NULL,prevcall=NULL, ploidy=2, type="PA" as.genind" So I really don't understand why it doesn't work ... I try to continue the analysis but of course R told me that my data set wasn't in genind format.... I join a part of my data set, maybe there is a problem with that... Sorry again for bothering you but I really don't know what's the problem.... Thanking you in advance, Best regards, Tyfanie Bourlet -----Message d'origine----- De : Jombart, Thibaut [mailto:t.jombart at imperial.ac.uk] Envoy? : lundi 22 juillet 2013 12:10 ? : tyfanie bourlet Objet : RE: sPCA with adegenet No worries. Sorry about that, I understand getting into R in the first place is a bit scary. I'm biaised of course, I would argue it's a worthwhile investment. Cheers Thibaut ________________________________________ From: tyfanie bourlet [tyfanie.bourlet at florimond-desprez.fr] Sent: 22 July 2013 07:06 To: Jombart, Thibaut Subject: RE: sPCA with adegenet Hello, Thank you very much, I will try to fix it all. Again thank you for the time you spent with me. Best Regards, Tyfanie Bourlet -----Message d'origine----- De : Jombart, Thibaut [mailto:t.jombart at imperial.ac.uk] Envoy? : vendredi 19 juillet 2013 17:14 ? : tyfanie bourlet; adegenet-forum at lists.r-forge.r-project.org Objet : RE: sPCA with adegenet Hello, unfortunately there is a number of basic errors here and I can't go through all of them. First, you do not assign the value of 'test' after using the constructor to any object. So 'test' remains unchanged. When calling the constructor, you have to specify type="PA" in your case, and I'm guessing ploidy is 1 too. Then, the call to data(test) does not make sense here. 'data' is used to load data objects distributed with R packages. I am guessing you are reusing code from the sPCA tutorial, but you need to adapt it to your object. As for the read.csv problem, this function is heavily used in R so it is unlikely to be a bug. The best thing to do here is to take a couple of days to get started with R in the first place and going through a basic introduction. A fairly complete one can be found on CRAN: http://cran.r-project.org/doc/manuals/r-release/R-intro.html Without a basic knowledge of R, analyzing your data in R is going to be hellish, and likely prone to unwanted mistakes/errors. Good luck and all the best 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 tyfanie bourlet [tyfanie.bourlet at florimond-desprez.fr] Sent: 19 July 2013 12:48 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] sPCA with adegenet 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 From josquint at unimelb.edu.au Tue Jul 23 15:41:12 2013 From: josquint at unimelb.edu.au (Josquin Frederick Tibbits) Date: Tue, 23 Jul 2013 13:41:12 +0000 Subject: [adegenet-forum] problems with new("genlight") Message-ID: I have recently updated to R-3.0.1 and to adegenet 1.3-9 the adegenet scripts I was running successfully in R-3.0.0 adgenet 1.3-8 are now failing when calling the new("genlight") functions, if there are arguments. I would be happy to set mc.cores to 1 but can not seem to pass this argument successfully. Help appreciated. Code is as follows: > new("genlight") === S4 class genlight === 0 genotypes, 0 binary SNPs > x <- new("genlight") > x === S4 class genlight === 0 genotypes, 0 binary SNPs ### Clearly OK > data.SNP[1:5, 1:5] 10015_641 c10016_302 c10017_644 c10126_263 10140_297 001031 0 0 2 2 0 001209 2 0 0 2 2 001298 2 0 2 2 0 001765 2 0 2 2 0 001032 2 0 2 2 0 > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, multicore=FALSE) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, multicore=FALSE, mc.cores=1) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, mc.cores=1) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows ## Even on the toy example I get > dat <- list(toto=c(1,1,0,0), titi=c(NA,1,1,0), tata=c(NA,0,3, NA)) > x <- new("genlight", dat) Error in mclapply(input$gen, function(e) new("SNPbin", e), mc.cores = n.cores, : 'mc.cores' > 1 is not supported on Windows > sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] adegenet_1.3-9 genalg_0.1.1 ade4_1.5-2 loaded via a namespace (and not attached): [1] ape_3.0-9 grid_3.0.1 igraph_0.6.5-2 lattice_0.20-15 MASS_7.3-26 nlme_3.1-109 tools_3.0.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From t.jombart at imperial.ac.uk Tue Jul 23 16:40:11 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Tue, 23 Jul 2013 14:40:11 +0000 Subject: [adegenet-forum] problems with new("genlight") In-Reply-To: References: Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638A8575@icexch-m1.ic.ac.uk> Hello, sorry about this, but there has been a change in the arguments. 'multicore' is now 'parallel' (the package multicore is being replaced by parallel). I realize this does not appear in the documentation of the constructor. I'll try to amend that in the next release. All the best 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 Josquin Frederick Tibbits [josquint at unimelb.edu.au] Sent: 23 July 2013 14:41 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] problems with new("genlight") I have recently updated to R-3.0.1 and to adegenet 1.3-9 the adegenet scripts I was running successfully in R-3.0.0 adgenet 1.3-8 are now failing when calling the new("genlight") functions, if there are arguments. I would be happy to set mc.cores to 1 but can not seem to pass this argument successfully. Help appreciated. Code is as follows: > new("genlight") === S4 class genlight === 0 genotypes, 0 binary SNPs > x <- new("genlight") > x === S4 class genlight === 0 genotypes, 0 binary SNPs ### Clearly OK > data.SNP[1:5, 1:5] 10015_641 c10016_302 c10017_644 c10126_263 10140_297 001031 0 0 2 2 0 001209 2 0 0 2 2 001298 2 0 2 2 0 001765 2 0 2 2 0 001032 2 0 2 2 0 > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, multicore=FALSE) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, multicore=FALSE, mc.cores=1) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, mc.cores=1) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows ## Even on the toy example I get > dat <- list(toto=c(1,1,0,0), titi=c(NA,1,1,0), tata=c(NA,0,3, NA)) > x <- new("genlight", dat) Error in mclapply(input$gen, function(e) new("SNPbin", e), mc.cores = n.cores, : 'mc.cores' > 1 is not supported on Windows > sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] adegenet_1.3-9 genalg_0.1.1 ade4_1.5-2 loaded via a namespace (and not attached): [1] ape_3.0-9 grid_3.0.1 igraph_0.6.5-2 lattice_0.20-15 MASS_7.3-26 nlme_3.1-109 tools_3.0.1 From josquint at unimelb.edu.au Wed Jul 24 04:46:51 2013 From: josquint at unimelb.edu.au (Josquin Frederick Tibbits) Date: Wed, 24 Jul 2013 02:46:51 +0000 Subject: [adegenet-forum] problems with new("genlight") In-Reply-To: <2CB2DA8E426F3541AB1907F98ABA6570638A8575@icexch-m1.ic.ac.uk> References: , <2CB2DA8E426F3541AB1907F98ABA6570638A8575@icexch-m1.ic.ac.uk> Message-ID: Hello Thibaut, Great. I found a workaround as well which was to redefine mclapply so it does not stop (deleted the stop line and the message) and it then just runs lapply. This worked fine. > mclapply <- function (X, FUN, ..., mc.preschedule = TRUE, mc.set.seed = TRUE, + mc.silent = FALSE, mc.cores = 1L, mc.cleanup = TRUE, mc.allow.recursive = TRUE) + { + cores <- as.integer(mc.cores) + if (cores < 1L) + stop("'mc.cores' must be >= 1") + if (cores > 1L) + lapply(X, FUN, ...) + } Josquin ________________________________________ From: Jombart, Thibaut [t.jombart at imperial.ac.uk] Sent: Wednesday, July 24, 2013 12:40 AM To: Josquin Frederick Tibbits; adegenet-forum at lists.r-forge.r-project.org Subject: RE: problems with new("genlight") Hello, sorry about this, but there has been a change in the arguments. 'multicore' is now 'parallel' (the package multicore is being replaced by parallel). I realize this does not appear in the documentation of the constructor. I'll try to amend that in the next release. All the best 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 Josquin Frederick Tibbits [josquint at unimelb.edu.au] Sent: 23 July 2013 14:41 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] problems with new("genlight") I have recently updated to R-3.0.1 and to adegenet 1.3-9 the adegenet scripts I was running successfully in R-3.0.0 adgenet 1.3-8 are now failing when calling the new("genlight") functions, if there are arguments. I would be happy to set mc.cores to 1 but can not seem to pass this argument successfully. Help appreciated. Code is as follows: > new("genlight") === S4 class genlight === 0 genotypes, 0 binary SNPs > x <- new("genlight") > x === S4 class genlight === 0 genotypes, 0 binary SNPs ### Clearly OK > data.SNP[1:5, 1:5] 10015_641 c10016_302 c10017_644 c10126_263 10140_297 001031 0 0 2 2 0 001209 2 0 0 2 2 001298 2 0 2 2 0 001765 2 0 2 2 0 001032 2 0 2 2 0 > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, multicore=FALSE) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, multicore=FALSE, mc.cores=1) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows > gl.ALL <- new("genlight", data.SNP, pop=data.annot[, 8], ploidy=2, mc.cores=1) Error in mclapply(1:nrow(input$gen), function(i) new("SNPbin", as.integer(input$gen[i, : 'mc.cores' > 1 is not supported on Windows ## Even on the toy example I get > dat <- list(toto=c(1,1,0,0), titi=c(NA,1,1,0), tata=c(NA,0,3, NA)) > x <- new("genlight", dat) Error in mclapply(input$gen, function(e) new("SNPbin", e), mc.cores = n.cores, : 'mc.cores' > 1 is not supported on Windows > sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] adegenet_1.3-9 genalg_0.1.1 ade4_1.5-2 loaded via a namespace (and not attached): [1] ape_3.0-9 grid_3.0.1 igraph_0.6.5-2 lattice_0.20-15 MASS_7.3-26 nlme_3.1-109 tools_3.0.1 From bouchet.sophie at free.fr Tue Jul 30 18:00:25 2013 From: bouchet.sophie at free.fr (sophie bouchet) Date: Tue, 30 Jul 2013 18:00:25 +0200 Subject: [adegenet-forum] dealing with colinear variables in dapc Message-ID: Dear Thibault, When running dapc on a dataset containing 174 individuals and 10000 SNP markers, I obtain this error message : Erreur dans lda.default(x, grouping, ...) : variables 1 2 appear to be constant within groups Do I need to remove colinear markers from the dataset before running dapc? Thanks, Sophie -------------- next part -------------- An HTML attachment was scrubbed... URL: From t.jombart at imperial.ac.uk Wed Jul 31 10:29:15 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Wed, 31 Jul 2013 08:29:15 +0000 Subject: [adegenet-forum] dealing with colinear variables in dapc In-Reply-To: References: Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638ABA95@icexch-m1.ic.ac.uk> Hello, collinearity is not the problem here, but variables with NULL variance give undefined F statistics and should this be discarded. Best 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 sophie bouchet [bouchet.sophie at free.fr] Sent: 30 July 2013 17:00 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] dealing with colinear variables in dapc Dear Thibault, When running dapc on a dataset containing 174 individuals and 10000 SNP markers, I obtain this error message : Erreur dans lda.default(x, grouping, ...) : variables 1 2 appear to be constant within groups Do I need to remove colinear markers from the dataset before running dapc? Thanks, Sophie From jryan.daniels at gmail.com Tue Jul 30 22:12:17 2013 From: jryan.daniels at gmail.com (Ryan Daniels) Date: Tue, 30 Jul 2013 22:12:17 +0200 Subject: [adegenet-forum] xvalDapc and Missing data Message-ID: Hey (Windows Vista, R 3.0.0) I've read in a genepop file with microsatellite data (diploid, 9 loci, 120 samples, 8 populations) and coverted it to genind. I was trying to use the xvalDapc function but I received the following error message: Error in dudi.pca(x, nf = n.pca.max, scannf = FALSE, center = center, : na entries in table I've checked, there are "NA"s and they correspond to my samples with missing data. I couldn't find anything on the web on how to deal with missing data for this function but I saw Thibaut suggested replacing NA's with uninformative mean values. here: http://r.789695.n4.nabble.com/PCA-with-NA-td840762.html Would this solution be permissible for this function and this type of data? Thank you in advance Ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: From t.jombart at imperial.ac.uk Wed Jul 31 10:41:09 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Wed, 31 Jul 2013 08:41:09 +0000 Subject: [adegenet-forum] xvalDapc and Missing data In-Reply-To: References: Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638ABACA@icexch-m1.ic.ac.uk> Hello, there is an illustration of how to replace NAs p17 of the "basics" vignette: http://cran.r-project.org/web/packages/adegenet/vignettes/adegenet-basics.pdf See 'scaleGen' and 'na.replace'. Cheers Thibaut -- ###################################### Dr Thibaut JOMBART MRC Centre for Outbreak Analysis and Modelling Department of Infectious Disease Epidemiology Imperial College - School of Public Health St Mary?s Campus Norfolk Place London W2 1PG United Kingdom Tel. : 0044 (0)20 7594 3658 t.jombart at imperial.ac.uk http://sites.google.com/site/thibautjombart/ http://adegenet.r-forge.r-project.org/ ________________________________________ From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Ryan Daniels [jryan.daniels at gmail.com] Sent: 30 July 2013 21:12 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] xvalDapc and Missing data Hey (Windows Vista, R 3.0.0) I've read in a genepop file with microsatellite data (diploid, 9 loci, 120 samples, 8 populations) and coverted it to genind. I was trying to use the xvalDapc function but I received the following error message: Error in dudi.pca(x, nf = n.pca.max, scannf = FALSE, center = center, : na entries in table I've checked, there are "NA"s and they correspond to my samples with missing data. I couldn't find anything on the web on how to deal with missing data for this function but I saw Thibaut suggested replacing NA's with uninformative mean values. here: http://r.789695.n4.nabble.com/PCA-with-NA-td840762.html Would this solution be permissible for this function and this type of data? Thank you in advance Ryan From bouchet.sophie at free.fr Wed Jul 31 11:42:44 2013 From: bouchet.sophie at free.fr (sophie bouchet) Date: Wed, 31 Jul 2013 11:42:44 +0200 Subject: [adegenet-forum] dealing with colinear variables in dapc In-Reply-To: <2CB2DA8E426F3541AB1907F98ABA6570638ABA95@icexch-m1.ic.ac.uk> References: <2CB2DA8E426F3541AB1907F98ABA6570638ABA95@icexch-m1.ic.ac.uk> Message-ID: Thanks, I guess this is within group variance? because I removed very low maf markers. Is there any function in adegenet that gives within group variable variance? Sophie 2013/7/31 Jombart, Thibaut > Hello, > > collinearity is not the problem here, but variables with NULL variance > give undefined F statistics and should this be discarded. > > Best > 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 sophie > bouchet [bouchet.sophie at free.fr] > Sent: 30 July 2013 17:00 > To: adegenet-forum at lists.r-forge.r-project.org > Subject: [adegenet-forum] dealing with colinear variables in dapc > > Dear Thibault, > > When running dapc on a dataset containing 174 individuals and 10000 SNP > markers, I obtain this error message : > > Erreur dans lda.default(x, grouping, ...) : > variables 1 2 appear to be constant within groups > > Do I need to remove colinear markers from the dataset before running dapc? > > Thanks, > > Sophie > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From t.jombart at imperial.ac.uk Wed Jul 31 11:50:13 2013 From: t.jombart at imperial.ac.uk (Jombart, Thibaut) Date: Wed, 31 Jul 2013 09:50:13 +0000 Subject: [adegenet-forum] dealing with colinear variables in dapc In-Reply-To: References: <2CB2DA8E426F3541AB1907F98ABA6570638ABA95@icexch-m1.ic.ac.uk>, Message-ID: <2CB2DA8E426F3541AB1907F98ABA6570638ABC46@icexch-m1.ic.ac.uk> Hello, no, I'm afraid there is not. If you send a reproducible example someone might figure out what's going on. Sorry, I'm on holiday and won't look again at my computer in a while. Best Thibaut ________________________________________ From: bouchet.sophie at gmail.com [bouchet.sophie at gmail.com] on behalf of sophie bouchet [bouchet.sophie at free.fr] Sent: 31 July 2013 10:42 To: Jombart, Thibaut Cc: adegenet-forum at lists.r-forge.r-project.org Subject: Re: [adegenet-forum] dealing with colinear variables in dapc Thanks, I guess this is within group variance? because I reu moved very low maf markers. Is there any function in adegenet that gives within group variable variance? Sophie 2013/7/31 Jombart, Thibaut > Hello, collinearity is not the problem here, but variables with NULL variance give undefined F statistics and should this be discarded. Best 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 sophie bouchet [bouchet.sophie at free.fr] Sent: 30 July 2013 17:00 To: adegenet-forum at lists.r-forge.r-project.org Subject: [adegenet-forum] dealing with colinear variables in dapc Dear Thibault, When running dapc on a dataset containing 174 individuals and 10000 SNP markers, I obtain this error message : Erreur dans lda.default(x, grouping, ...) : variables 1 2 appear to be constant within groups Do I need to remove colinear markers from the dataset before running dapc? Thanks, Sophie From bouchet.sophie at free.fr Wed Jul 31 12:47:18 2013 From: bouchet.sophie at free.fr (sophie bouchet) Date: Wed, 31 Jul 2013 12:47:18 +0200 Subject: [adegenet-forum] dealing with colinear variables in dapc In-Reply-To: <2CB2DA8E426F3541AB1907F98ABA6570638ABC46@icexch-m1.ic.ac.uk> References: <2CB2DA8E426F3541AB1907F98ABA6570638ABA95@icexch-m1.ic.ac.uk> <2CB2DA8E426F3541AB1907F98ABA6570638ABC46@icexch-m1.ic.ac.uk> Message-ID: when removing markers with NULL variance within one of the two main groups, it works. 2013/7/31 Jombart, Thibaut > > Hello, > > no, I'm afraid there is not. > > If you send a reproducible example someone might figure out what's going > on. Sorry, I'm on holiday and won't look again at my computer in a while. > > Best > Thibaut > ________________________________________ > From: bouchet.sophie at gmail.com [bouchet.sophie at gmail.com] on behalf of > sophie bouchet [bouchet.sophie at free.fr] > Sent: 31 July 2013 10:42 > To: Jombart, Thibaut > Cc: adegenet-forum at lists.r-forge.r-project.org > Subject: Re: [adegenet-forum] dealing with colinear variables in dapc > > Thanks, > > I guess this is within group variance? because I reu moved very low maf > markers. > > Is there any function in adegenet that gives within group variable > variance? > > Sophie > > > 2013/7/31 Jombart, Thibaut t.jombart at imperial.ac.uk>> > Hello, > > collinearity is not the problem here, but variables with NULL variance > give undefined F statistics and should this be discarded. > > Best > Thibaut > ________________________________________ > From: adegenet-forum-bounces at lists.r-forge.r-project.org adegenet-forum-bounces at lists.r-forge.r-project.org> [ > adegenet-forum-bounces at lists.r-forge.r-project.org adegenet-forum-bounces at lists.r-forge.r-project.org>] on behalf of sophie > bouchet [bouchet.sophie at free.fr] > Sent: 30 July 2013 17:00 > To: adegenet-forum at lists.r-forge.r-project.org adegenet-forum at lists.r-forge.r-project.org> > Subject: [adegenet-forum] dealing with colinear variables in dapc > > Dear Thibault, > > When running dapc on a dataset containing 174 individuals and 10000 SNP > markers, I obtain this error message : > > Erreur dans lda.default(x, grouping, ...) : > variables 1 2 appear to be constant within groups > > Do I need to remove colinear markers from the dataset before running dapc? > > Thanks, > > Sophie > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: