<html><body><div style="font-family: trebuchet ms,sans-serif; font-size: 12pt; color: #000000"><div>You could do it this way, too:</div><div><br></div><div><p style="margin: 0px;" data-mce-style="margin: 0px;">library(adegenet)<br>data("nancycats")</p><p style="margin: 0px;" data-mce-style="margin: 0px;">n.pop <- seppop(nancycats)</p><p style="margin: 0px;" data-mce-style="margin: 0px;">mean.hobs <- do.call("c", lapply(n.pop, function(x) mean(summary(x)$Hobs)))</p><p style="margin: 0px;" data-mce-style="margin: 0px;">mean.hobs[is.nan(mean.hobs)] <- NA</p><p style="margin: 0px;" data-mce-style="margin: 0px;">barplot(mean.hobs)</p><p style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p style="margin: 0px;" data-mce-style="margin: 0px;">Cheers,</p><p style="margin: 0px;" data-mce-style="margin: 0px;">Roman</p></div><div><br></div><div><span name="x"></span>----<br>In god we trust, all others bring data.<span name="x"></span><br></div><div><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Simon Nadeau" <simon.nadeau.ubc@gmail.com><br><b>To: </b>"Thibaut Jombart" <t.jombart@imperial.ac.uk><br><b>Cc: </b>adegenet-forum@lists.r-forge.r-project.org<br><b>Sent: </b>Monday, November 23, 2015 10:21:03 PM<br><b>Subject: </b>Re: [adegenet-forum] How to get observed heterozygosity per population<br><div><br></div><div dir="ltr">Hi,<div><br></div><div> This worked. I could not figure out how to access $Hobs for each population without using a for loop.</div><div><br></div><div><div>x.pop = seppop(x)</div><div>summary.by.pop = lapply(x.pop, summary)</div><div>Hobs.ls = rep(NA, length(summary.by.pop))</div><div>for (i in 1:length(summary.by.pop)){</div><div> Hobs.ls[i] = mean(summary.by.pop[[i]]$Hobs)</div><div>}</div><div>barplot(Hobs.ls, names.arg = levels(pop(x)), las = 2, main = "Observed heterozygosity", ylab = "Ho")</div></div><div><br></div><div>Thank you very much for your help,</div><div><br></div><div>Simon</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 23, 2015 at 10:38 AM, Jombart, Thibaut <span dir="ltr"><<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">You can use 'seppop' to split your data by population, and then lapply over it to get population specific summaries (averaging over loci if you need).<br>
<div><br>
Makes sense?<br>
<br>
Cheers<br>
Thibaut<br>
<div style="font-family:Tahoma;font-size:13px">
<div><span size="2" data-mce-style="font-size: small;" style="font-size: small;"><span style="font-size:10pt">
<div> <br>
<br>
</div>
</span></span></div>
</div>
</div>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div style="direction:ltr"><span color="#000000" face="Tahoma" size="2" data-mce-style="color: #000000; font-family: Tahoma; font-size: small;" style="color: #000000; font-family: Tahoma; font-size: small;"><b>From:</b> Simon Nadeau [<a href="mailto:simon.nadeau.ubc@gmail.com" target="_blank">simon.nadeau.ubc@gmail.com</a>]<br>
<b>Sent:</b> 23 November 2015 18:19<br>
<b>To:</b> Maria Guerrina<br>
<b>Cc:</b> Jombart, Thibaut; <a href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a><br>
<b>Subject:</b> Re: [adegenet-forum] How to get observed heterozygosity per population<br>
</span><br>
</div><div><div class="h5">
<div></div>
<div>
<div dir="ltr">Hi Thibault,
<div><br>
</div>
<div> Thank you very much for your help. I just downloaded the dev version but I get the same results using summary(x) than with the previous version. summary gives me expected and observed heterozygosity but per loci:</div>
<div><br>
</div>
<div>summary(x)$Hobs</div>
<div><br>
</div>
<div> What I would like to have is Hobs <span data-mce-style="text-decoration: underline;" style="text-decoration: underline;">per population</span> instead. Something similar to the function Hs but for Hobs. Is there anything like that in adegenet? I tried basic.stats from Hierfstat as Maria suggested, but I got an error message, probably
due to something wrong in the way I formatted the data.</div>
<div><br>
</div>
<div>Simon</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Nov 23, 2015 at 6:58 AM, Maria Guerrina <span dir="ltr">
<<a href="mailto:maria.guerrina@edu.unige.it" target="_blank">maria.guerrina@edu.unige.it</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">Hi Thibaut!
<div>I have a problem similar to Simon.</div>
<div>I have tried to use the function 'summary', but I get 0 both for the observed heterozigosity both for the expected one...</div>
<div>I have tried to use the function 'basic.stats' in hierfstat, but it doesn't give a result for Ho, in my case with my data.</div>
<div><br>
</div>
<div>any idea?</div>
<div>Thanks!</div>
<div>Maria<br>
<div><span style="border-collapse:separate;color:rgb(0,0,0);font-family:Helvetica;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="border-collapse:separate;color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium">
<div style="word-wrap:break-word"><span style="border-collapse:separate;color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium">
<div style="word-wrap:break-word">
<div>--</div>
<div>Maria Guerrina PhD</div>
<div>
<div>Università di Genova</div>
<div>DISTAV</div>
<div>Corso Dogali 1M</div>
<div>I - 16136 GENOVA (Italy)</div>
</div>
<div><a href="mailto:maria.guerrina@edu.unige.it" target="_blank">maria.guerrina@edu.unige.it</a></div>
<div><br>
</div>
</div>
</span><br>
</div>
</span><br>
</span><br>
</div>
<br>
<div>
<div>
<div>
<div>On 23/nov/2015, at 13.11, Jombart, Thibaut wrote:</div>
<br>
</div>
</div>
<blockquote><span style="border-collapse:separate;font-family:Helvetica;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<div>
<div>
<div>
<div style="direction:ltr;font-family:Tahoma;color:rgb(0,0,0);font-size:10pt">
Hello,<span> </span><br>
<br>
have you tried 'summary'? Note, the current devel version is better (previous summary was returning invisibly a list).<span> </span><br>
<br>
Cheers<br>
Thibaut<br>
<div><br>
<div style="font-family:Tahoma;font-size:13px">
<div><span size="2" data-mce-style="font-size: small;" style="font-size: small;"><span style="font-size:10pt">
<div><br>
</div>
</span></span></div>
</div>
</div>
<div style="font-family:'Times New Roman';color:rgb(0,0,0);font-size:16px">
<hr>
<div style="direction:ltr"><span color="#000000" face="Tahoma" size="2" data-mce-style="color: #000000; font-family: Tahoma; font-size: small;" style="color: #000000; font-family: Tahoma; font-size: small;"><b>From:</b><span> </span><a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org" target="_blank">adegenet-forum-bounces@lists.r-forge.r-project.org</a><span> </span>[<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org" target="_blank">adegenet-forum-bounces@lists.r-forge.r-project.org</a>]
on behalf of Simon Nadeau [<a href="mailto:simon.nadeau.ubc@gmail.com" target="_blank">simon.nadeau.ubc@gmail.com</a>]<br>
<b>Sent:</b><span> </span>19 November 2015 23:00<br>
<b>To:</b><span> </span><a href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a><br>
<b>Subject:</b><span> </span>[adegenet-forum] How to get observed heterozygosity per population<br>
</span><br>
</div>
<div></div>
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div> I have recently been using the various features of adegenet unsing genind objects and I works great so far. However, I can't seem to be able to find easy summary stats:</div>
<div><br>
</div>
<div>Observed heterozygosity per population: this would be very handy but I only found the function Hs (expected heterozygosity).</div>
<div><br>
</div>
<div>Global allele frequencies per loci: there is a nice histogram of minor allele frequencies on page 30 of the adegenet genomic tutorial, but I can't find how to generate the same plot using genind objects.</div>
<div><br>
</div>
<div>Thank you very much for your help,</div>
<div><br>
</div>
<div>Simon<br clear="all">
<div><br>
</div>
--<span> </span><br>
<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><span color="#3d85c6" size="4" data-mce-style="color: #3d85c6; font-size: large;" style="color: #3d85c6; font-size: large;">Simon Nadeau, M. Sc.</span></div>
<div><span color="#3d85c6" data-mce-style="color: #3d85c6;" style="color: #3d85c6;"><span size="3" data-mce-style="font-size: medium;" style="font-size: medium;">Biologiste / Biologist</span></span></div>
<div><strong><span color="#007f00" size="3" data-mce-style="color: #007f00; font-size: medium;" style="color: #007f00; font-size: medium;"></span></strong><br>
</div>
<div>
<div>Ressources naturelles Canada, Service canadien des forêts, Centre de foresterie des Laurentides / Natural Resources Canada, Canadian Forest Service, Laurentian Forestry Centre</div>
<div>1055 rue du P.E.P.S., C.P. 10380 succ. Sainte-Foy, Québec (Québec), Canada G1V 4C7</div>
</div>
<div><a href="mailto:Simon.Nadeau.UBC@gmail.com" style="font-size:12.8px" target="_blank">Simon.Nadeau@a</a><span style="font-size:12.8px;color:rgb(0,0,255)"><a href="http://lumni.ubc.ca" target="_blank">lumni.UBC.ca</a>, </span><span data-mce-style="color: #0000ff; font-size: 12.8px; text-decoration: underline;" style="color: #0000ff; font-size: 12.8px; text-decoration: underline;"><span> </span>
<div style="display:inline!important"><a href="mailto:Simon.Nadeau@RNCan-NRCan.gc.ca" target="_blank">Simon.Nadeau@canada.ca</a></div>
</span></div>
<div><span style="font-size:12.8px">Tel: <a href="tel:%28604%29%20349-5196" target="_blank">
(604) 349-5196</a></span><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</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" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a></div>
</span></blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<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><span color="#3d85c6" size="4" data-mce-style="color: #3d85c6; font-size: large;" style="color: #3d85c6; font-size: large;">Simon Nadeau, M. Sc.</span></div>
<div><span color="#3d85c6" data-mce-style="color: #3d85c6;" style="color: #3d85c6;"><span size="3" data-mce-style="font-size: medium;" style="font-size: medium;">Biologiste / Biologist</span></span></div>
<div><strong><span color="#007f00" size="3" data-mce-style="color: #007f00; font-size: medium;" style="color: #007f00; font-size: medium;"></span></strong><br>
</div>
<div>
<div>Ressources naturelles Canada, Service canadien des forêts, Centre de foresterie des Laurentides / Natural Resources Canada, Canadian Forest Service, Laurentian Forestry Centre</div>
<div>1055 rue du P.E.P.S., C.P. 10380 succ. Sainte-Foy, Québec (Québec), Canada G1V 4C7</div>
</div>
<div><a href="mailto:Simon.Nadeau.UBC@gmail.com" style="font-size:12.8000001907349px" target="_blank">Simon.Nadeau@a</a><span style="font-size:12.8000001907349px;color:rgb(0,0,255)"><a href="http://lumni.ubc.ca" target="_blank">lumni.UBC.ca</a>, </span><span data-mce-style="color: #0000ff; font-size: 12.8px; text-decoration: underline;" style="color: #0000ff; font-size: 12.8px; text-decoration: underline;">
<div style="display:inline!important"><a href="mailto:Simon.Nadeau@RNCan-NRCan.gc.ca" target="_blank">Simon.Nadeau@canada.ca</a></div>
</span></div>
<div><span style="font-size:12.8000001907349px">Tel: <a href="tel:%28604%29%20349-5196" target="_blank">(604) 349-5196</a></span><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><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>
<span size="4" color="#3d85c6" data-mce-style="color: #3d85c6; font-size: large;" style="color: #3d85c6; font-size: large;">Simon Nadeau, M. Sc.</span></div><div><span color="#3d85c6" data-mce-style="color: #3d85c6;" style="color: #3d85c6;"><span size="3" data-mce-style="font-size: medium;" style="font-size: medium;">Biologiste / Biologist</span></span></div><div><strong><span color="#007f00" size="3" data-mce-style="color: #007f00; font-size: medium;" style="color: #007f00; font-size: medium;"></span></strong><br></div><div><div>Ressources naturelles Canada, Service canadien des forêts, Centre de foresterie des Laurentides / Natural Resources Canada, Canadian Forest Service, Laurentian Forestry Centre</div><div>1055 rue du P.E.P.S., C.P. 10380 succ. Sainte-Foy, Québec (Québec), Canada G1V 4C7</div></div><div><a href="mailto:Simon.Nadeau.UBC@gmail.com" style="font-size:12.8000001907349px" target="_blank">Simon.Nadeau@a</a><span style="font-size:12.8000001907349px;color:rgb(0,0,255)"><a href="http://lumni.ubc.ca" target="_blank">lumni.UBC.ca</a>, </span><span data-mce-style="color: #0000ff; font-size: 12.8px; text-decoration: underline;" style="color: #0000ff; font-size: 12.8px; text-decoration: underline;"><div style="display:inline!important"><a href="mailto:Simon.Nadeau@RNCan-NRCan.gc.ca" target="_blank">Simon.Nadeau@canada.ca</a></div></span></div><div><span style="font-size:12.8000001907349px">Tel: (604) 349-5196</span><br></div></div></div></div></div></div></div></div></div></div></div></div>
</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>