<html><body><div style="font-family: trebuchet ms,sans-serif; font-size: 12pt; color: #000000"><div>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:</div><div><br data-mce-bogus="1"></div><div style="padding-left: 30px;"><span style="color: #000000; font-family: 'courier new', courier, monaco, monospace, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none;" data-mce-style="color: #000000; font-family: 'courier new', courier, monaco, monospace, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none;">df2genind(X = xy[, -1], sep = "/", ploidy = 4)</span></div><div><br></div><div data-marker="__SIG_PRE__">----<br>In god we trust, all others bring data.</div><br><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>From: </b>"Roman Luštrik" <roman.lustrik@biolitika.si><br><b>To: </b>"Jessica Perez Alquicira" <perezalquicira@gmail.com><br><b>Cc: </b>"Thibaut Jombart" <thibautjombart@gmail.com>, adegenet-forum@lists.r-forge.r-project.org<br><b>Sent: </b>Tuesday, January 3, 2017 11:52:37 PM<br><b>Subject: </b>Re: [adegenet-forum] tetraploid DAPC<br></div><br><div data-marker="__QUOTED_TEXT__"><div style="font-family: trebuchet ms,sans-serif; font-size: 12pt; color: #000000;" data-mce-style="font-family: trebuchet ms,sans-serif; font-size: 12pt; color: #000000;"><div>Hi Jessica,</div><br><div>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.</div><br><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">library(adegenet)</span><br><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">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"</span><br><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">xy <- read.table(text = x, sep = ",")</span><br><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">df2genind(X = xy[, c(-1, -2)], sep = "/", ploidy = 4)</span></div><br><div>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:</div><br><div style="padding-left: 30px;" data-mce-style="padding-left: 30px;"><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">rownames(xy) <- xy[, 1]</span><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">xy[, 1] <- NULL</span><br><br><span style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">df2genind(X = xy[, -2], sep = "/", ploidy = 4)</span></div><br><div>Cheers,</div><div>Roman</div><br><div>----<br>In god we trust, all others bring data.</div><br><hr id="zwchr"><div><b>From: </b>"Jessica Perez Alquicira" <perezalquicira@gmail.com><br><b>To: </b>"Thibaut Jombart" <thibautjombart@gmail.com><br><b>Cc: </b>adegenet-forum@lists.r-forge.r-project.org<br><b>Sent: </b>Tuesday, January 3, 2017 6:02:04 PM<br><b>Subject: </b>Re: [adegenet-forum] tetraploid DAPC<br></div><br><div><div dir="ltr"><div>Dear Thibaut, I have this file format (including 149 samples, pop number, 8 loci with four alleles)</div><div>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</div><br><div>I am doing the following things:</div><div><div>obj<-read.csv("testCSV.csv",header=FALSE)</div></div><div><div>obj2 <- df2genind(obj, sep = "/", ind.names = TRUE, loc.names = FALSE, pop = TRUE, ploidy = 4, type = c("codom"))</div></div><br><div>And I am getting this error:</div><div><div>Error in `rownames<-`(`*tmp*`, value = "TRUE") : </div><div> length of 'dimnames' [1] not equal to array extent</div></div><br><div>Not sure what to do, any help?</div><div>Thanks so much for your support</div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-02 10:04 GMT-06:00 Thibaut Jombart <span dir="ltr"><<a href="mailto:thibautjombart@gmail.com" target="_blank">thibautjombart@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div dir="ltr">Dear Jessica, <br><div>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:</div><br><div>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 "/") </div><div>001-010-001-002</div><br><div>2) read them into R using read.table or read.csv</div><br><div>3) use df2genind to convert data into a genind object</div><br><div>The basics tutorial should help with this last step:</div><div><a href="https://github.com/thibautjombart/adegenet/wiki/Tutorials" target="_blank">https://github.com/thibautjombart/adegenet/wiki/Tutorials</a><br></div><br><div>Best</div><div>Thibaut</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_-907260325560700026gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div><div><br>--<br>Dr Thibaut Jombart<br>Lecturer, Department of Infectious Disease Epidemiology, <span style="font-size: 12.8px;" data-mce-style="font-size: 12.8px;">Imperial College London</span></div></div><div><span style="font-size: 12.8px;" data-mce-style="font-size: 12.8px;">Head of RECON: </span><span style="font-size: 12.8px;" data-mce-style="font-size: 12.8px;"><a href="http://repidemicsconsortium.org" target="_blank">repidemicsconsortium.org</a></span><br></div></div><div><a href="http://sites.google.com/site/thibautjombart/" style="font-size: 12.8px;" target="_blank" data-mce-style="font-size: 12.8px;">sites.google.com/site/thibautjombart/</a><br></div><div><a href="http://github.com/thibautjombart" target="_blank">github.com/thibautjombart</a></div>Twitter: <a href="http://twitter.com/TeebzR" target="_blank">@TeebzR</a><br></div><div dir="ltr">+44(0)20 7594 3658</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote"><div><div class="h5">On 30 November 2016 at 13:28, Jessica Perez Alquicira <span dir="ltr"><<a href="mailto:perezalquicira@gmail.com" target="_blank">perezalquicira@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div><div class="h5"><div dir="ltr"><div>Hi, I would like to do a dapc on tetraploid data. My file format is in structure.</div><div>I have not find this information in the manual. Could you please let me know how could I do that.</div><br><div>Best</div></div>
<br></div></div>_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br></blockquote></div><br></div>
</blockquote></div><br></div>
<br>_______________________________________________<br>adegenet-forum mailing list<br>adegenet-forum@lists.r-forge.r-project.org<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</div></div><br></div></div></body></html>