[Genabel-commits] r1354 - pkg/GenABEL/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 30 17:34:41 CET 2013


Author: lckarssen
Date: 2013-10-30 17:34:41 +0100 (Wed, 30 Oct 2013)
New Revision: 1354

Modified:
   pkg/GenABEL/R/grammar.R
Log:
Fixed code layout in GenABEL's grammar function. No functional changes.


Modified: pkg/GenABEL/R/grammar.R
===================================================================
--- pkg/GenABEL/R/grammar.R	2013-10-30 16:26:39 UTC (rev 1353)
+++ pkg/GenABEL/R/grammar.R	2013-10-30 16:34:41 UTC (rev 1354)
@@ -1,56 +1,56 @@
 #' GRAMMAR test for association in samples with genetic structure
-#' 
-#' Fast approximate test for association between a trait and genetic polymorphism, 
-#' in samples with genetic sub-structure (e.g. relatives). The function implements 
-#' several varieties of GRAMMAR ('gamma','gc', and 'raw'). 
-#' 
-#' With 'raw' argument, 
-#' the original GRAMMAR (Aulchenko et al., 2007) is implemented. This method 
-#' is conservative and generates biased estimates of regression coefficients. 
-#' 
-#' With 'gc' argument, the GRAMMAR-GC (Amin et al., 2007) is implemented. 
-#' This method solves conservativity of the test, but the Genomic Control (GC) 
-#' lambda is by definition "1" and can not serve as an indicator of goodness of 
-#' the model; also, the estimates of regression coefficients are biased (the 
-#' same as in 'raw' GRAMMAR). 
-#' 
-#' GRAMMAR-Gamma (default 'gamma' argument) solves these problems, producing 
-#' correct distribution of the test statistic, interpretable value of GC Lambda, 
-#' and unbiased estimates of the regression coefficients. All together, the 
-#' default 'gamma' method is recommended for use. 
-#' 
+#'
+#' Fast approximate test for association between a trait and genetic polymorphism,
+#' in samples with genetic sub-structure (e.g. relatives). The function implements
+#' several varieties of GRAMMAR ('gamma','gc', and 'raw').
+#'
+#' With 'raw' argument,
+#' the original GRAMMAR (Aulchenko et al., 2007) is implemented. This method
+#' is conservative and generates biased estimates of regression coefficients.
+#'
+#' With 'gc' argument, the GRAMMAR-GC (Amin et al., 2007) is implemented.
+#' This method solves conservativity of the test, but the Genomic Control (GC)
+#' lambda is by definition "1" and can not serve as an indicator of goodness of
+#' the model; also, the estimates of regression coefficients are biased (the
+#' same as in 'raw' GRAMMAR).
+#'
+#' GRAMMAR-Gamma (default 'gamma' argument) solves these problems, producing
+#' correct distribution of the test statistic, interpretable value of GC Lambda,
+#' and unbiased estimates of the regression coefficients. All together, the
+#' default 'gamma' method is recommended for use.
+#'
 #' @param polyObject object returned by \code{\link{polygenic}} function
 #' @param data object of \code{\link{gwaa.data-class}}
 #' @param method to be used, one of 'gamma','gc', or 'raw'
 #' @param propPs proportion of non-corrected P-values used to estimate the inflation factor Lambda,
 #' passed directly to the \code{\link{estlambda}}
-#' @param ... arguments passed to the function used for computations,  
+#' @param ... arguments passed to the function used for computations,
 #' (\code{\link{qtscore}})
-#' 
+#'
 #' @return Object of scan.gwaa-class
-#' 
+#'
 #' @seealso \code{\link{polygenic}}, \code{\link{mmscore}}, \code{\link{qtscore}}
-#' 
-#' @references 
-#' 
-#' GRAMMAR-Raw: 
-#' Aulchenko YS, de Koning DJ, Haley C. 
-#' Genomewide rapid association using mixed model and regression: a fast and 
-#' simple method for genomewide pedigree-based quantitative trait loci 
+#'
+#' @references
+#'
+#' GRAMMAR-Raw:
+#' Aulchenko YS, de Koning DJ, Haley C.
+#' Genomewide rapid association using mixed model and regression: a fast and
+#' simple method for genomewide pedigree-based quantitative trait loci
 #' association analysis. Genetics. 2007 Sep;177(1):577-85.
-#' 
-#' GRAMMAR-GC: 
-#' Amin N, van Duijn CM, Aulchenko YS. 
+#'
+#' GRAMMAR-GC:
+#' Amin N, van Duijn CM, Aulchenko YS.
 #' A genomic background based method for association analysis in related individuals.
 #' PLoS One. 2007 Dec 5;2(12):e1274.
-#' 
-#' GRAMMAR-Gamma: 
-#' Svischeva G, Axenovich TI, Belonogova NM, van Duijn CM, Aulchenko YS. 
-#' Rapid variance components-based method for whole-genome association analysis. 
-#' Nature Genetics. 2012 44:1166-1170. doi:10.1038/ng.2410 
-#' 
-#' @examples 
-#' # Using clean ge03d2 data 
+#'
+#' GRAMMAR-Gamma:
+#' Svischeva G, Axenovich TI, Belonogova NM, van Duijn CM, Aulchenko YS.
+#' Rapid variance components-based method for whole-genome association analysis.
+#' Nature Genetics. 2012 44:1166-1170. doi:10.1038/ng.2410
+#'
+#' @examples
+#' # Using clean ge03d2 data
 #' data(ge03d2.clean)
 #' #take small piece for speed
 #' ge03d2.clean <- ge03d2.clean[1:200,]
@@ -76,42 +76,53 @@
 #' summary(mm)
 #' summary(grGamma)
 #' summary(grGc)
-#' 
+#'
 #' @author Gulnara Svisheva, Yurii Aulchenko
-#' 
+#'
 #' @keywords htest
-#' 
+#'
 "grammar" <-
-		function(polyObject,data,method=c("gamma","gc","raw"), propPs=1.0, ... ) 
+    function(polyObject, data, method=c("gamma","gc","raw"), propPs=1.0, ... )
 {
-	method <- match.arg(method)
-	if (method == "gamma") {
-		out <- qtscore(polyObject$pgresidualY,data=data,clambda=TRUE, ... )
-		# correct test and beta values
-		out at results[,"chi2.1df"] <- out at results[,"chi2.1df"]/polyObject$grammarGamma$Test
-		out at results[,"effB"] <- out at results[,"effB"]/polyObject$grammarGamma$Beta
-		# re-compute standard errors (c2 = (b/se)^2; se = b/sqrt(c2))
-		out at results[,"se_effB"] <- abs(out at results[,"effB"])/sqrt(out at results[,"chi2.1df"])
-		# recompute p-values
-		out at results[,"P1df"] <- pchisq(out at results[,"chi2.1df"],df=1,lower.tail=FALSE)
-		# recompute Lambda
-		out at lambda <- estlambda(out[,"chi2.1df"],plot=FALSE,proportion=propPs)
-		if (out at lambda$estimate <= 1) {
-			warning("estimate of Lambda < 1, constraining to 1")
-			out at lambda$estimate <- 1.0
-			out at lambda$se <- NA
-		}
-	} else if (method == "gc") {
-		out <- qtscore(polyObject$pgres,data=data,clambda=FALSE, propPs=propPs, ... )
-	} else if (method == "raw") {
-		out <- qtscore(polyObject$pgres,data=data,clambda=TRUE, propPs=propPs, ... )
-	} else {
-		stop("method should be one of 'gamma','gc', or 'raw'")
-	}
-	# set uncorrectet stats to NA to avoid confusion
-	out at results[,"effAB"] <- out at results[,"effBB"] <- out at results[,"chi2.2df"] <- 
-			out at results[,"P2df"] <- NA
-	out at call <- match.call()
-	# return results
-	return(out);
-}
\ No newline at end of file
+    method <- match.arg(method)
+    if (method == "gamma") {
+        out <- qtscore(polyObject$pgresidualY, data=data, clambda=TRUE, ... )
+
+        ## correct test and beta values
+        out at results[,"chi2.1df"] <-
+            out at results[, "chi2.1df"]/polyObject$grammarGamma$Test
+        out at results[,"effB"] <- out at results[, "effB"]/polyObject$grammarGamma$Beta
+
+        ## re-compute standard errors (c2 = (b/se)^2; se = b/sqrt(c2))
+        out at results[,"se_effB"] <-
+            abs(out at results[, "effB"])/sqrt(out at results[, "chi2.1df"])
+        ## recompute p-values
+        out at results[,"P1df"] <-
+            pchisq(out at results[,"chi2.1df"], df=1, lower.tail=FALSE)
+        ## recompute Lambda
+        out at lambda <- estlambda(out[, "chi2.1df"],
+                                plot=FALSE,
+                                proportion=propPs)
+
+        if (out at lambda$estimate <= 1) {
+            warning("estimate of Lambda < 1, constraining to 1")
+            out at lambda$estimate <- 1.0
+            out at lambda$se <- NA
+        }
+    } else if (method == "gc") {
+        out <- qtscore(polyObject$pgres, data=data,
+                       clambda=FALSE, propPs=propPs, ... )
+    } else if (method == "raw") {
+        out <- qtscore(polyObject$pgres, data=data,
+                       clambda=TRUE, propPs=propPs, ... )
+    } else {
+        stop("method should be one of 'gamma','gc', or 'raw'")
+    }
+
+    ## set uncorrectet stats to NA to avoid confusion
+    out at results[,"effAB"] <- out at results[,"effBB"] <- out at results[,"chi2.2df"] <-
+        out at results[,"P2df"] <- NA
+    out at call <- match.call()
+    ## return results
+    return(out);
+}



More information about the Genabel-commits mailing list