[adegenet-commits] r664 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 8 17:51:49 CEST 2010


Author: jombart
Date: 2010-09-08 17:51:49 +0200 (Wed, 08 Sep 2010)
New Revision: 664

Modified:
   pkg/R/fstat.R
   pkg/man/fstat.Rd
Log:
now Hs are weighted by pop sizes


Modified: pkg/R/fstat.R
===================================================================
--- pkg/R/fstat.R	2010-09-08 15:36:00 UTC (rev 663)
+++ pkg/R/fstat.R	2010-09-08 15:51:49 UTC (rev 664)
@@ -54,8 +54,10 @@
 
     ## function to compute one Fst ##
     f1 <- function(pop1, pop2){ # pop1 and pop2 are genind obj. with a single pop each
+        n1 <- nrow(pop1 at tab)
+        n2 <- nrow(pop2 at tab)
         temp <- repool(pop1,pop2)
-        b <- mean(Hs(temp))
+        b <- weighted.mean(Hs(temp), c(n1,n2)) # mean Hs is weighted for pop sizes
         pop(temp) <- NULL
         a <- Hs(temp)
         return((a-b)/a)

Modified: pkg/man/fstat.Rd
===================================================================
--- pkg/man/fstat.Rd	2010-09-08 15:36:00 UTC (rev 663)
+++ pkg/man/fstat.Rd	2010-09-08 15:51:49 UTC (rev 664)
@@ -36,12 +36,13 @@
   \code{\link{gstat.randtest}}
 }
 \details{
-  Let A and B be two populations, with expected heterozygocity Hs(A) and
-  Hs(B), respectively. We denote Ht the expected heterozygocity of a
-  population pooling A and B. Then, the pairwise Fst \eqn{Fst(A,B)} is
-  computed as:\cr
+  Let A and B be two populations of population sizes \eqn{n_A} and
+  \eqn{n_B}, with expected heterozygosity Hs(A) and Hs(B),
+  respectively. We denote Ht the expected heterozygosity of a population
+  pooling A and B. Then, the pairwise Fst \eqn{Fst(A,B)} is computed
+  as:\cr
 
-  \eqn{\frac{(Ht - (Hs(A)+Hs(B))/2 )}{Ht} \cr
+  \eqn{\frac{(Ht - (n_A Hs(A) + n_B Hs(B))/(n_A + n_B) )}{Ht} \cr
 }
 \author{ Thibaut Jombart \email{t.jombart at imperial.ac.uk} }
 \examples{



More information about the adegenet-commits mailing list