[adegenet-forum] How to get observed heterozygosity per population
Roman Lustrik
roman.lustrik at biolitika.si
Tue Nov 24 09:46:05 CET 2015
You could do it this way, too:
library(adegenet)
data("nancycats")
n.pop <- seppop(nancycats)
mean.hobs <- do.call("c", lapply(n.pop, function(x) mean(summary(x)$Hobs)))
mean.hobs[is.nan(mean.hobs)] <- NA
barplot(mean.hobs)
Cheers,
Roman
----
In god we trust, all others bring data.
----- Original Message -----
From: "Simon Nadeau" <simon.nadeau.ubc at gmail.com>
To: "Thibaut Jombart" <t.jombart at imperial.ac.uk>
Cc: adegenet-forum at lists.r-forge.r-project.org
Sent: Monday, November 23, 2015 10:21:03 PM
Subject: Re: [adegenet-forum] How to get observed heterozygosity per population
Hi,
This worked. I could not figure out how to access $Hobs for each population without using a for loop.
x.pop = seppop(x)
summary.by.pop = lapply(x.pop, summary)
Hobs.ls = rep(NA, length(summary.by.pop))
for (i in 1:length(summary.by.pop)){
Hobs.ls[i] = mean(summary.by.pop[[i]]$Hobs)
}
barplot(Hobs.ls, names.arg = levels(pop(x)), las = 2, main = "Observed heterozygosity", ylab = "Ho")
Thank you very much for your help,
Simon
On Mon, Nov 23, 2015 at 10:38 AM, Jombart, Thibaut < t.jombart at imperial.ac.uk > wrote:
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).
Makes sense?
Cheers
Thibaut
From: Simon Nadeau [ simon.nadeau.ubc at gmail.com ]
Sent: 23 November 2015 18:19
To: Maria Guerrina
Cc: Jombart, Thibaut; adegenet-forum at lists.r-forge.r-project.org
Subject: Re: [adegenet-forum] How to get observed heterozygosity per population
Hi Thibault,
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:
summary(x)$Hobs
What I would like to have is Hobs per population 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.
Simon
On Mon, Nov 23, 2015 at 6:58 AM, Maria Guerrina < maria.guerrina at edu.unige.it > wrote:
<blockquote>
Hi Thibaut!
I have a problem similar to Simon.
I have tried to use the function 'summary', but I get 0 both for the observed heterozigosity both for the expected one...
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.
any idea?
Thanks!
Maria
--
Maria Guerrina PhD
Università di Genova
DISTAV
Corso Dogali 1M
I - 16136 GENOVA (Italy)
maria.guerrina at edu.unige.it
On 23/nov/2015, at 13.11, Jombart, Thibaut wrote:
<blockquote>
Hello,
have you tried 'summary'? Note, the current devel version is better (previous summary was returning invisibly a list).
Cheers
Thibaut
From: adegenet-forum-bounces at lists.r-forge.r-project.org [ adegenet-forum-bounces at lists.r-forge.r-project.org ] on behalf of Simon Nadeau [ simon.nadeau.ubc at gmail.com ]
Sent: 19 November 2015 23:00
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] How to get observed heterozygosity per population
Hi,
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:
Observed heterozygosity per population: this would be very handy but I only found the function Hs (expected heterozygosity).
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.
Thank you very much for your help,
Simon
--
Simon Nadeau, M. Sc.
Biologiste / Biologist
Ressources naturelles Canada, Service canadien des forêts, Centre de foresterie des Laurentides / Natural Resources Canada, Canadian Forest Service, Laurentian Forestry Centre
1055 rue du P.E.P.S., C.P. 10380 succ. Sainte-Foy, Québec (Québec), Canada G1V 4C7
Simon.Nadeau at a lumni.UBC.ca ,
Simon.Nadeau at canada.ca
Tel: (604) 349-5196
_______________________________________________
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
</blockquote>
--
Simon Nadeau, M. Sc.
Biologiste / Biologist
Ressources naturelles Canada, Service canadien des forêts, Centre de foresterie des Laurentides / Natural Resources Canada, Canadian Forest Service, Laurentian Forestry Centre
1055 rue du P.E.P.S., C.P. 10380 succ. Sainte-Foy, Québec (Québec), Canada G1V 4C7
Simon.Nadeau at a lumni.UBC.ca ,
Simon.Nadeau at canada.ca
Tel: (604) 349-5196
</blockquote>
--
Simon Nadeau, M. Sc.
Biologiste / Biologist
Ressources naturelles Canada, Service canadien des forêts, Centre de foresterie des Laurentides / Natural Resources Canada, Canadian Forest Service, Laurentian Forestry Centre
1055 rue du P.E.P.S., C.P. 10380 succ. Sainte-Foy, Québec (Québec), Canada G1V 4C7
Simon.Nadeau at a lumni.UBC.ca ,
Simon.Nadeau at canada.ca
Tel: (604) 349-5196
_______________________________________________
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/20151124/139f0a5d/attachment.html>
More information about the adegenet-forum
mailing list