<div dir="ltr">Dear Laura, <div><br></div><div>This coding is indeed not compatible with the expected input for df2genind. The function takes in characters coding alleles, not genotypes. Imagine a locus is heterozygote A / T, with A as ref. The input for df2genind would be "A / T" while yours is "1". In fact the coding you describe is the one used in the genlight class, which is a lot more compact. You might want to use it; for instance:</div><div><br></div><div><div>> set.seed(1)</div><div>> m <-  matrix(sample(0:2, 30, replace=TRUE), nrow=5)</div><div>> m</div><div>     [,1] [,2] [,3] [,4] [,5] [,6]</div><div>[1,]    0    2    0    1    2    1</div><div>[2,]    1    2    0    2    0    0</div><div>[3,]    1    1    2    2    1    1</div><div>[4,]    2    1    1    1    0    2</div><div>[5,]    0    0    2    2    0    1</div><div><br></div><div>> x <- new("genlight", m)</div><div>> x</div><div> /// GENLIGHT OBJECT /////////</div><div><br></div><div> // 5 genotypes,  6 binary SNPs, size: 9.2 Kb</div><div> 0 (0 %) missing data</div><div><br></div><div> // Basic content</div><div>   @gen: list of 5 SNPbin</div><div><br></div><div> // Optional content</div><div>   @other: a list containing: elements without names </div><div><br></div><div>> plot(x)</div><div><br></div></div><div><br></div><div>Note that of ploidy is constant across individuals, you can also do without - your data format is already compatible with most methods.</div><div><br></div><div>Best</div><div>Thibaut</div><div>  </div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><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">Imperial College London</span></div></div><div><span style="font-size:12.8px">Head of RECON: </span><span 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">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></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On 28 October 2016 at 03:18, Laura Taillebois <span dir="ltr"><<a href="mailto:Laura.Taillebois@cdu.edu.au" target="_blank">Laura.Taillebois@cdu.edu.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>Hi All adegenet guru,</div>
<div><br>
</div>
<div>I am having troubles getting <i>df2genind</i> function to find the correct number of alleles in my dataset.</div>
<div><br>
</div>
<div>My data are SNPs data (2 alleles at each locus). The genotypes are encoded in one single column such as 0=reference homozygote, 1=SNP homozygote and 2=heterozygote. And I importe them as data frame from a comma separated .csv file.</div>
<div><br>
</div>
<div>When I apply the function df2genind,</div>
<div><br>
</div>
<div>
<div>genind <- df2genind(locus, sep=",", ncode=1, NA.char="NA", ploidy=2)</div>
<div><br>
</div>
<div>the genind object returned is as follow:</div>
<div><br>
</div>
<div>/// GENIND OBJECT /////////</div>
<div><br>
</div>
<div> // 1 individual; 2,078 loci; 5,752 alleles; size: 1.2 Mb</div>
<div><br>
</div>
<div> // Basic content</div>
<div>   @tab:  1 x 5752 matrix of allele counts</div>
<div>   @loc.n.all: number of alleles per locus (range: 2-3)</div>
<div>   @loc.fac: locus factor for the 5752 columns of @tab</div>
<div>   @all.names: list of allele names for each locus</div>
<div>   @ploidy: ploidy of each individual  (range: 2-2)</div>
<div>   @type:  codom</div>
<div>   @call: .local(x = x, i = i, j = j, drop = drop)</div>
<div><br>
</div>
<div> // Optional content</div>
<div>   - empty -</div>
</div>
<div><br>
</div>
<div>There should be only 4,158 alleles in the object and not 5,752. Is there a problem with using this type of 0,1,2 code for the genotypes? Should my input have 2 columns for each genotype ?</div>
<div><br>
</div>
<div>Thanks for your support!</div>
<div><br>
</div>
<div>Cheers, Laura</div>
</div>

<br>______________________________<wbr>_________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.<wbr>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-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/adegenet-forum</a><br></blockquote></div><br></div>