[adegenet-commits] r81 - in pkg: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Mar 28 17:46:12 CET 2008
Author: jombart
Date: 2008-03-28 17:46:12 +0100 (Fri, 28 Mar 2008)
New Revision: 81
Added:
pkg/R/fstat.R
pkg/man/fstat.Rd
Modified:
pkg/DESCRIPTION
pkg/TODO
pkg/man/gstat.randtest.Rd
Log:
Added fstat function and doc.
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2008-03-28 14:08:32 UTC (rev 80)
+++ pkg/DESCRIPTION 2008-03-28 16:46:12 UTC (rev 81)
@@ -9,4 +9,4 @@
Description: Classes and functions for genetic data analysis within the multivariate framework.
License: GPL (>=2)
LazyLoad: yes
-Collate: classes.R auxil.R makefreq.R chooseCN.R dist.genpop.R export.R gstat.randtest.R HWE.R import.R monmonier.R coords.monmonier.R spca.R spca.rtests.R zzz.R hybridize.R
\ No newline at end of file
+Collate: classes.R auxil.R makefreq.R chooseCN.R dist.genpop.R export.R gstat.randtest.R HWE.R import.R monmonier.R coords.monmonier.R spca.R spca.rtests.R zzz.R hybridize.R fstat.R
\ No newline at end of file
Added: pkg/R/fstat.R
===================================================================
--- pkg/R/fstat.R (rev 0)
+++ pkg/R/fstat.R 2008-03-28 16:46:12 UTC (rev 81)
@@ -0,0 +1,19 @@
+#################
+# fstat function
+#################
+fstat <- function(x, pop=NULL, fstonly=FALSE){
+ ## misc checks
+ if(!is.genind(x)) stop("x is not a valid genind object")
+ if(!require(hierfstat)) stop("hierfstat package is required. Please install it.")
+
+ if(is.null(pop)) pop <- x at pop
+ if(is.null(pop)) stop("no pop factor provided")
+ if(length(pop)!=nrow(x at tab)) stop("pop has a wrong length.")
+
+ ## computations
+ dat <- genind2hierfstat(x)[,-1]
+ res <- varcomp.glob(levels=data.frame(pop), loci=dat)$F
+
+ if(fstonly) {res <- res[1,1]}
+ return(res)
+}
Modified: pkg/TODO
===================================================================
--- pkg/TODO 2008-03-28 14:08:32 UTC (rev 80)
+++ pkg/TODO 2008-03-28 16:46:12 UTC (rev 81)
@@ -38,7 +38,7 @@
* Implement a method to merge different markers for the same individuals
* Implement spatial weights derived from inverse spatial distances in chooseCN -- done (TJ)
* Build accessors for marker names, indiv names, pop names, spatial coords, ...
-* Implement a Fst wrapper for genind objects
+* Implement a Fst wrapper for genind objects -- done (TJ)
*
# TESTING:
Added: pkg/man/fstat.Rd
===================================================================
--- pkg/man/fstat.Rd (rev 0)
+++ pkg/man/fstat.Rd 2008-03-28 16:46:12 UTC (rev 81)
@@ -0,0 +1,31 @@
+\encoding{UTF-8}
+\name{fstat}
+\alias{fstat}
+\title{F statistics for genind objects}
+\description{This function is a wrapper of \code{varcomp.glob} for
+ \linkS4class{genind} objects. It computes F statistics (Fst, Fis, Fit)
+ given a set of genotypes and a grouping factor.
+}
+\usage{
+fstat(x, pop=NULL, fstonly=FALSE)
+}
+\arguments{
+ \item{x}{an object of class \linkS4class{genind}.}
+ \item{pop}{a factor giving the 'population' of each individual. If NULL,
+ pop is seeked from x\@pop. Note that the term population refers in
+ fact to any grouping of individuals'.}
+\item{fstonly}{a logical stating whether only the Fst value should be
+ returned (TRUE) instead of all F statistics (FALSE, default).}
+ }
+\value{A matrix of F statistics.}
+\seealso{\code{\link[pkg:hierfstat]{varcomp.glob}},
+ \code{\link{gstat.randtest}}
+}
+\author{ Thibaut Jombart \email{jombart at biomserv.univ-lyon1.fr} }
+\examples{
+if(require(hierfstat)){
+data(nancycats)
+fstat(nancycats)
+}
+}
+\keyword{multivariate}
\ No newline at end of file
Modified: pkg/man/gstat.randtest.Rd
===================================================================
--- pkg/man/gstat.randtest.Rd 2008-03-28 14:08:32 UTC (rev 80)
+++ pkg/man/gstat.randtest.Rd 2008-03-28 16:46:12 UTC (rev 81)
@@ -44,6 +44,7 @@
\value{Returns an object of the class \code{randtest} (package \code{ade4}).
}
\seealso{\code{\link[pkg:hierfstat]{g.stats.glob}},
+ \code{\link{fstat}},
\code{\link[pkg:hierfstat]{test.g}},\code{\link[pkg:hierfstat]{test.within}},
\code{\link[pkg:hierfstat]{test.between}},\code{\link[pkg:ade4]{as.randtest}},
\code{\link{genind2hierfstat}}
More information about the adegenet-commits
mailing list