[adegenet-forum] tetraploid DAPC

Roman Luštrik roman.lustrik at biolitika.si
Tue Jan 3 23:54:44 CET 2017


Just realized there was a mistake in the last line of my code. Since we remove the sample name from as the first column, the second column becomes first. This is the bane of working with indices and not column names (where things can be handles in a more general manner). In any case, this is the correct line: 

df2genind(X = xy[, -1], sep = "/", ploidy = 4) 

---- 
In god we trust, all others bring data. 


From: "Roman Luštrik" <roman.lustrik at biolitika.si> 
To: "Jessica Perez Alquicira" <perezalquicira at gmail.com> 
Cc: "Thibaut Jombart" <thibautjombart at gmail.com>, adegenet-forum at lists.r-forge.r-project.org 
Sent: Tuesday, January 3, 2017 11:52:37 PM 
Subject: Re: [adegenet-forum] tetraploid DAPC 

Hi Jessica, 

you forgot to exclude the columns not responsible for forming genotypes. Also, you misunderstood how ind.names and loc.names work. If not NULL, you should provide the arguments with vectors. 

library(adegenet) 

x <- "Buen137,1,04/07/04/07,11/13/11/13,05/07/05/07,06/19/21/06,05/06/05/06,03/03/03/03,03/05/03/05,07/07/07/07" 

xy <- read.table(text = x, sep = ",") 

df2genind(X = xy[, c(-1, -2)], sep = "/", ploidy = 4) 

If you want for ind.names to work out of the box, you could remove the columns for names and place it as a rownames, like so: 

rownames(xy) <- xy[, 1] 
xy[, 1] <- NULL 

df2genind(X = xy[, -2], sep = "/", ploidy = 4) 

Cheers, 
Roman 

---- 
In god we trust, all others bring data. 


From: "Jessica Perez Alquicira" <perezalquicira at gmail.com> 
To: "Thibaut Jombart" <thibautjombart at gmail.com> 
Cc: adegenet-forum at lists.r-forge.r-project.org 
Sent: Tuesday, January 3, 2017 6:02:04 PM 
Subject: Re: [adegenet-forum] tetraploid DAPC 

Dear Thibaut, I have this file format (including 149 samples, pop number, 8 loci with four alleles) 
Buen137,1,04/07/04/07,11/13/11/13,05/07/05/07,06/19/21/06,05/06/05/06,03/03/03/03,03/05/03/05,07/07/07/07 

I am doing the following things: 
obj<-read.csv("testCSV.csv",header=FALSE) 
obj2 <- df2genind(obj, sep = "/", ind.names = TRUE, loc.names = FALSE, pop = TRUE, ploidy = 4, type = c("codom")) 

And I am getting this error: 
Error in `rownames<-`(`*tmp*`, value = "TRUE") : 
length of 'dimnames' [1] not equal to array extent 

Not sure what to do, any help? 
Thanks so much for your support 


2017-01-02 10:04 GMT-06:00 Thibaut Jombart < thibautjombart at gmail.com > : 



Dear Jessica, 
as you might have noted from the doc of read.structure, the function only work with diploid data. Tetraploid data are no problem in adegenet, but you'll need to get them in differently. I would suggest the following workflow: 

1) get your data in a txt/csv file in a format where data at each locus are coded as character strings where alleles are separated by a given symbol (e.g. "-", or "/") 
001-010-001-002 

2) read them into R using read.table or read.csv 

3) use df2genind to convert data into a genind object 

The basics tutorial should help with this last step: 
https://github.com/thibautjombart/adegenet/wiki/Tutorials 

Best 
Thibaut 


-- 
Dr Thibaut Jombart 
Lecturer, Department of Infectious Disease Epidemiology, Imperial College London 
Head of RECON: repidemicsconsortium.org 
sites.google.com/site/thibautjombart/ 
github.com/thibautjombart 
Twitter: @TeebzR 
+44(0)20 7594 3658 

On 30 November 2016 at 13:28, Jessica Perez Alquicira < perezalquicira at gmail.com > wrote: 

BQ_BEGIN

Hi, I would like to do a dapc on tetraploid data. My file format is in structure. 
I have not find this information in the manual. Could you please let me know how could I do that. 

Best 

_______________________________________________ 
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 





BQ_END



_______________________________________________ 
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 

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


More information about the adegenet-forum mailing list