<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">Thank you for your patience. I will try to answer this as best I can.</div><div class=""><br class=""></div><div class="">Note that this is explicitly an adegenet forum, so the question is a bit out of place. I am copying the response to the poppr forum. Additionally, it would be good to know what versions of R, adegenet, and poppr you are using. </div><div class=""><br class=""></div><div class="">Please find my answers below</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class="">In the output I have 13072 rows, 6536 unique "alleles names" x 2 (M and<br class="">P). Why don't I have all loci in my dataset ( I should have 24996 rows)??.<br class="">Many of these alleles are not private in none of the two pops.. so it is<br class="">not only the loci with private alleles.</blockquote><br class=""></div><div>The core part of private_alleles will report alleles that are represented by fewer than two populations in the current data set [1]. This is why you do not have all alleles represented. If you want a table that reports counts of alleles per population, you can convert your data to a genpop object with genind2genpop(). </div><div><br class=""></div><div>I suspect that the reason you are getting zero counts in your data is because this represents a subset of a larger data set and the alleles that were present in the broader data set were not dropped. For example, I can represent the same pattern with the nancycats data set:</div><div><br class=""></div><div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">suppressPackageStartupMessages(library("poppr"))</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">data(nancycats)</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">all_cats <- private_alleles(nancycats, allele ~ .)</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">dim(all_cats)</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> [1] 17 13</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">all_cats[, 1:5] # shows private alleles in three populations</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#>     fca8.117 fca8.119 fca8.127 fca43.157 fca77.132</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P01        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P02        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P03        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P04        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P05        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P06        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P07        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P08        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P09        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P10        0        0        0         1         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P11        0        0        0         0         1</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P12        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P13        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P14        1        1        1         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P15        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P16        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P17        0        0        0         0         0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">two_cats <- private_alleles(nancycats[pop = 1:2], allele ~ .)</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">dim(two_cats)</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> [1]  2 83</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">two_cats[, 1:5] # shows that these alleles do not exist in these two</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#>     fca8.117 fca8.119 fca8.121 fca8.123 fca8.127</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P01        0        0        0        0        0</span></font></div><div><font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">#> P02        0        0        0        0        0</span></font></div><div><br class=""></div><div><blockquote type="cite" class="">For example, for "1219:12:-" , population M has 4 private alleles.  Am I<br class="">correct that this means there are 4 individuals of population M that hold a<br class="">private allele at this locus?<br class="">     population        allele count<br class="">13             M    588:43:+.1     0<br class="">14             P    588:43:+.1     0<br class="">15             M   1086:34:-.1     0<br class="">16             P   1086:34:-.1     0<br class="">17             M   1219:12:-.1     4</blockquote><br class=""></div><div>Yes. This is correct.</div></div><div><br class=""></div><div><blockquote type="cite" class="">Then, I count the number of population -private alleles across loci with<br class="">*n.pAlleles*<-pa.all%>%group_by(population)%>%summarise(sum(count))%>%as.data.frame<br class="">#count total nb of private alleles, loci pooled<br class=""><blockquote type="cite" class="">n.pAlleles<br class=""></blockquote> population sum(count)<br class="">1          M       1648<br class="">2          P       1684<br class=""><br class="">And I count the number of loci with population -private alleles with<br class="">pa.all1<-filter(pa.all, count !=0)    #remove loci with  of 0 p.a.<br class="">*n.pLocus*<-pa.all1 %>% count(population) %>%as.data.frame  #count per pop<br class="">the nb of loci with at least 1 private allele<br class=""><blockquote type="cite" class="">n.pLocus<br class=""></blockquote> population   n<br class="">1          M 864<br class="">2          P 742<br class=""><br class="">I get very different results for the two measures, which I didn't expect.<br class="">Am I interpreting well the results?</blockquote></div><div class=""><br class=""></div>These represent the differences between count.alleles = TRUE and count.alleles = FALSE.</div><div class=""><br class=""></div><div class="">Let's say you had a clonal data set where every individual was duplicated perfectly in each population, the first result would give 3296 for M and 3368 for P because the number of alleles in the pool has doubled. The second result would give 864 for M and 742 for P because the number of allelic states has remained the same.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">Also, I realised I get exactly the same results using "form =loci~." in the<br class="">private_alleles function, but the first is much much faster. This is weird.<br class="">I think in the two cases it gives me the number of alleles per<br class="">population....  So I don't get what is " loci~ " for.</blockquote><br class=""></div><div class="">I'm afraid I do not have enough information to give you an answer as to why you are getting the same result. What I suspect is that your data may have been mis-formatted on import. You have binary alleles, but only the 1s are being counted. It may be that zero alleles were considered missing somewhere, so it would be good to make sure that alleles are not represented as zero. If you used vcfR2genind to import your data, you can use the return.alleles = TRUE argument to return the alleles as the actual allele call (which was fixed in the latest version of vcfR)</div><div class=""><br class=""></div><div class="">I hope that helps.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Zhian</div><div class=""><div><br class=""></div><div>[1] For those interested here is the precise code that does that: <a href="https://github.com/grunwaldlab/poppr/blob/af877c388899298197cd6b76fbd8876f59815833/R/Index_calculations.r#L1096-L1097" class="">https://github.com/grunwaldlab/poppr/blob/af877c388899298197cd6b76fbd8876f59815833/R/Index_calculations.r#L1096-L1097</a><br class=""><blockquote type="cite" class=""><div class=""><div class="">Date: Tue, 28 Apr 2020 13:16:36 +0200<br class="">From: Amaranta Fontcuberta <<a href="mailto:amaranta.fontcuberta@unil.ch" class="">amaranta.fontcuberta@unil.ch</a>><br class="">To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org" class="">adegenet-forum@lists.r-forge.r-project.org</a><br class="">Subject: [adegenet-forum] interpretation results private_alleles<br class="">Message-ID:<br class=""><span class="Apple-tab-span" style="white-space:pre">  </span><<a href="mailto:CAG+96r8SdfFfhqaAu39sk=0-yp3HghaOWn=BwkHOYwq261xpfA@mail.gmail.com" class="">CAG+96r8SdfFfhqaAu39sk=0-yp3HghaOWn=BwkHOYwq261xpfA@mail.gmail.com</a>><br class="">Content-Type: text/plain; charset="utf-8"<br class=""><br class="">Dear Zhian,<br class=""><br class="">I calculate tne number of alleles per population with poppr. I get<br class="">unexpected results and some weird behavior of the private_alleles function,<br class="">so I would like to confirm I am understanding well what the function is<br class="">doing and I am interpreting the results correctly. Thanks in advance for<br class="">your help!<br class=""><br class="">I have a genind object with 27 individuals and 12.498 loci (bi allelic<br class="">data, 0/1).  I have 2 populations called M and P.<br class="">I calculate the nb of private alleles per population with<br class=""><blockquote type="cite" class="">pa.all<-private_alleles(derbo.gd<br class=""></blockquote>,form=alleles~.,level="population",report="data.frame")<br class=""><br class=""> In the output I have 13072 rows, 6536 unique "alleles names" x 2 (M and<br class="">P). Why don't I have all loci in my dataset ( I should have 24996 rows)??.<br class="">Many of these alleles are not private in none of the two pops.. so it is<br class="">not only the loci with private alleles.<br class=""><br class="">For example, for "1219:12:-" , population M has 4 private alleles.  Am I<br class="">correct that this means there are 4 individuals of population M that hold a<br class="">private allele at this locus?<br class="">      population        allele count<br class="">13             M    588:43:+.1     0<br class="">14             P    588:43:+.1     0<br class="">15             M   1086:34:-.1     0<br class="">16             P   1086:34:-.1     0<br class="">17             M   1219:12:-.1     4<br class=""><br class="">Then, I count the number of population -private alleles across loci with<br class="">*n.pAlleles*<-pa.all%>%group_by(population)%>%summarise(sum(count))%>%as.data.frame<br class="">#count total nb of private alleles, loci pooled<br class=""><blockquote type="cite" class="">n.pAlleles<br class=""></blockquote>  population sum(count)<br class="">1          M       1648<br class="">2          P       1684<br class=""><br class="">And I count the number of loci with population -private alleles with<br class="">pa.all1<-filter(pa.all, count !=0)    #remove loci with  of 0 p.a.<br class="">*n.pLocus*<-pa.all1 %>% count(population) %>%as.data.frame  #count per pop<br class="">the nb of loci with at least 1 private allele<br class=""><blockquote type="cite" class="">n.pLocus<br class=""></blockquote>  population   n<br class="">1          M 864<br class="">2          P 742<br class=""><br class="">I get very different results for the two measures, which I didn't expect.<br class="">Am I interpreting well the results?<br class=""><br class="">Also, I realised I get exactly the same results using "form =loci~." in the<br class="">private_alleles function, but the first is much much faster. This is weird.<br class="">I think in the two cases it gives me the number of alleles per<br class="">population....  So I don't get what is " loci~ " for.<br class=""><br class="">Thanks in advance for your advice,<br class=""><br class="">All the best,<br class=""><br class=""><br class=""><blockquote type="cite" class="">derbo.gd<br class=""></blockquote>/// GENIND OBJECT /////////<br class=""> // 27 individuals; 12,498 loci; 24,996 alleles; size: 8.4 Mb<br class=""> // Basic content<br class="">   @tab:  27 x 24996 matrix of allele counts<br class="">   @loc.n.all: number of alleles per locus (range: 2-2)<br class="">   @loc.fac: locus factor for the 24996 columns of @tab<br class="">   @all.names: list of allele names for each locus<br class="">   @ploidy: ploidy of each individual  (range: 2-2)<br class="">   @type:  codom<br class="">   @call: .local(x = x, i = i, j = j, drop = drop)<br class=""><br class=""> // Optional content<br class="">   @pop: population of each individual (group size range: 13-14)<br class=""><blockquote type="cite" class=""><br class=""><a href="mailto:derbo.gd@loc.fac" class="">derbo.gd@loc.fac</a><br class=""></blockquote>   [1] 47:42:-    47:42:-    69:32:+    69:32:+    170:70:+   170:70:+<br class="">255:71:+   255:71:+   318:29:+<br class="">  [10] 318:29:+   413:44:-   413:44:-   447:82:+   447:82:+   471:26:+<br class="">471:26:+   541:74:-   541:74:-<br class="">  [19] 588:43:+   588:43:+   702:20:+   702:20:+   745:45:-   745:45:-<br class="">749:18:+   749:18:+   770:10:+<br class="">  [28] 770:10:+   854:6:+    854:6:+    1086:34:-  1086:34:-  1142:62:+<br class=""> 1142:62:+  1183:42:+  1183:42:+<br class=""><br class=""><blockquote type="cite" class="">pa.all<-private_alleles(derbo.gd<br class=""></blockquote>,form=alleles~.,level="population",report="data.frame")<br class=""><blockquote type="cite" class="">pa.all (alllele ~pop)<br class=""></blockquote>      population        allele count<br class="">1              M     69:32:+.1     0<br class="">2              P     69:32:+.1     0<br class="">3              M    170:70:+.1     0<br class="">4              P    170:70:+.1     0<br class="">5              M    255:71:+.1     0<br class="">6              P    255:71:+.1     0<br class="">7              M    318:29:+.1     0<br class="">8              P    318:29:+.1     0<br class="">9              M    447:82:+.1     0<br class="">10             P    447:82:+.1     0<br class="">11             M    541:74:-.1     0<br class="">12             P    541:74:-.1     0<br class="">13             M    588:43:+.1     0<br class="">14             P    588:43:+.1     0<br class="">15             M   1086:34:-.1     0<br class="">16             P   1086:34:-.1     0<br class="">17             M   1219:12:-.1     4<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">pa.all (loci~pop)<br class=""></blockquote>      population       locus count<br class="">1              M     69:32:+     0<br class="">2              P     69:32:+     0<br class="">3              M    170:70:+     0<br class="">4              P    170:70:+     0<br class="">5              M    255:71:+     0<br class="">6              P    255:71:+     0<br class="">7              M    318:29:+     0<br class="">8              P    318:29:+     0<br class="">9              M    447:82:+     0<br class="">10             P    447:82:+     0<br class="">11             M    541:74:-     0<br class="">12             P    541:74:-     0<br class="">13             M    588:43:+     0<br class="">14             P    588:43:+     0<br class="">15             M   1086:34:-     0<br class="">16             P   1086:34:-     0<br class="">17             M   1219:12:-     4<br class=""><br class=""><br class="">----------------------------------------------------------<br class="">Amaranta Fontcuberta, assistante diplômée<br class="">Dept. Écologie et Évolution<br class="">Université de Lausanne<br class="">-------------- next part --------------<br class="">An HTML attachment was scrubbed...<br class="">URL: <<a href="http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20200428/79603835/attachment-0001.html" class="">http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20200428/79603835/attachment-0001.html</a>><br class=""><br class="">------------------------------<br class=""><br class="">Subject: Digest Footer<br class=""><br class="">_______________________________________________<br class="">adegenet-forum mailing list<br class=""><a href="mailto:adegenet-forum@lists.r-forge.r-project.org" class="">adegenet-forum@lists.r-forge.r-project.org</a><br class="">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum<br class=""><br class="">------------------------------<br class=""><br class="">End of adegenet-forum Digest, Vol 137, Issue 5<br class="">**********************************************<br class=""></div></div></blockquote></div><br class=""></div></body></html>