[Genabel-commits] r769 - in pkg/GenABEL: . R inst/unitTests man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 25 00:18:31 CEST 2011


Author: yurii
Date: 2011-08-25 00:18:31 +0200 (Thu, 25 Aug 2011)
New Revision: 769

Added:
   pkg/GenABEL/R/recodeChromosome.R
   pkg/GenABEL/inst/unitTests/runit.recodeChromosome.R
   pkg/GenABEL/man/recodeChromosome.Rd
   pkg/GenABEL/tests/gatest.illu
   pkg/GenABEL/tests/gatest.map
   pkg/GenABEL/tests/gatest.ped
   pkg/GenABEL/tests/gatest.phe
   pkg/GenABEL/tests/gatest.tfam
   pkg/GenABEL/tests/gatest.tped
   pkg/GenABEL/tests/gatest1.phe
   pkg/GenABEL/tests/gatest1.tfam
   pkg/GenABEL/tests/gatest1.tped
Modified:
   pkg/GenABEL/CHANGES.LOG
   pkg/GenABEL/NAMESPACE
   pkg/GenABEL/R/GenABEL-package.R
   pkg/GenABEL/R/check.marker.R
   pkg/GenABEL/R/polygenic.R
   pkg/GenABEL/R/polygenic_hglm.R
   pkg/GenABEL/R/polylik.R
   pkg/GenABEL/R/ss.R
   pkg/GenABEL/generate_documentation.R
   pkg/GenABEL/inst/unitTests/report.html
   pkg/GenABEL/inst/unitTests/report.txt
   pkg/GenABEL/inst/unitTests/reportSummary.txt
   pkg/GenABEL/man/GenABEL-package.Rd
   pkg/GenABEL/man/check.marker.Rd
   pkg/GenABEL/man/convert.snp.tped.Rd
   pkg/GenABEL/man/polygenic.Rd
   pkg/GenABEL/man/polygenic_hglm.Rd
   pkg/GenABEL/man/scan.glm.2D.Rd
Log:
Update of 'polygenic_hglm' by Xia Shen. Quote:
We've updated the hglm package to version 1.2-2 recently on CRAN, where 
the major updates include:
- Sparse matrix implementation
- Multiple random effects
- Function hglm2() which accepts lme4-style formula input
In this update of polygenic_hglm() the speed could be slightly faster than 
before since the hglm() now uses sparse matrix technique (however I don't 
expect it to be much faster since the kinship matrix is always dense). Other 
modifications are:
- The current update of hglm package does not spit out profile log-likelihood 
since we haven't perfectly solved the likelihood computation for multiple random 
effects yet. But since polygenic_hglm() only needs one random effect (polygenic 
effect), I've re-implemented the likelihood computation directly in 
polygenic_hglm(), and no need to specify 'method = "REML"' anymore.
- In order to solve the problem from the forum about inputting formula as 
'y' or 'y ~ 1', I've added a check before creating the model.frame, so now 
 both types of inputs should work.

Added 'recodeChromosome' function, which must be handy when e.g. importing data 
from other software which uses integer for sex chromosomes and other non-autosomes
(X, Y, mt).

+> tutorial genetic data QC - list all options, do not use default?

'check.marker' added "none" (equal to ibs.mrk = -1); set "both" to default

Updated documentation for 'scan.glm.2D'.

Added GRAMMAR+ transformation and computation of GRAMMAR+ 
correction factors to 'polygenic'.

The default value for the stand option to convert.snp.tped() is now "u", 
instead of "+". Now convert.snp.tped() and convert.snp.ped() have the 
same defaults.


Modified: pkg/GenABEL/CHANGES.LOG
===================================================================
--- pkg/GenABEL/CHANGES.LOG	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/CHANGES.LOG	2011-08-24 22:18:31 UTC (rev 769)
@@ -1,7 +1,41 @@
-The default value for the stand option to convert.snp.tped() is now "u", instead of "+". Now convert.snp.tped() and convert.snp.ped() have the same defaults.
+*** v. 1.6-8 (2011.08.23)
 
-*** v. 1.6-8 (2011.07.15)
+Update of 'polygenic_hglm' by Xia Shen. Quote:
+We've updated the hglm package to version 1.2-2 recently on CRAN, where 
+the major updates include:
+- Sparse matrix implementation
+- Multiple random effects
+- Function hglm2() which accepts lme4-style formula input
+In this update of polygenic_hglm() the speed could be slightly faster than 
+before since the hglm() now uses sparse matrix technique (however I don't 
+expect it to be much faster since the kinship matrix is always dense). Other 
+modifications are:
+- The current update of hglm package does not spit out profile log-likelihood 
+since we haven't perfectly solved the likelihood computation for multiple random 
+effects yet. But since polygenic_hglm() only needs one random effect (polygenic 
+effect), I've re-implemented the likelihood computation directly in 
+polygenic_hglm(), and no need to specify 'method = "REML"' anymore.
+- In order to solve the problem from the forum about inputting formula as 
+'y' or 'y ~ 1', I've added a check before creating the model.frame, so now 
+ both types of inputs should work.
 
+Added 'recodeChromosome' function, which must be handy when e.g. importing data 
+from other software which uses integer for sex chromosomes and other non-autosomes
+(X, Y, mt).
+
++> tutorial genetic data QC - list all options, do not use default?
+
+'check.marker' added "none" (equal to ibs.mrk = -1); set "both" to default
+
+Updated documentation for 'scan.glm.2D'.
+
+Added GRAMMAR+ transformation and computation of GRAMMAR+ 
+correction factors to 'polygenic'.
+
+The default value for the stand option to convert.snp.tped() is now "u", 
+instead of "+". Now convert.snp.tped() and convert.snp.ped() have the 
+same defaults.
+
 Added patch of bug [#1322] + regression test (contributed 
 by Nicola Pirastu, see  
 https://lists.r-forge.r-project.org/pipermail/genabel-devel/2011-May/000276.html). 

Modified: pkg/GenABEL/NAMESPACE
===================================================================
--- pkg/GenABEL/NAMESPACE	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/NAMESPACE	2011-08-24 22:18:31 UTC (rev 769)
@@ -84,6 +84,7 @@
 	polygenic_hglm,
 	r2fast,
 	r2fast.old,
+	recodeChromosome,
 	reconstructNPs,
 	redundant,
 	refresh.gwaa.data,

Modified: pkg/GenABEL/R/GenABEL-package.R
===================================================================
--- pkg/GenABEL/R/GenABEL-package.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/R/GenABEL-package.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -61,6 +61,12 @@
 #' 
 #' To load the data, see \code{\link{load.gwaa.data}}.
 #' 
+#' For conversion to DatABEL format (used by ProbABEL and some other 
+#' GenABEL suite packages), see 
+#' \code{\link{impute2databel}}, 
+#' \code{\link{impute2mach}}, 
+#' \code{\link{mach2databel}}. 
+#' 
 #' For data managment and manipulations see
 #' \code{\link{merge.gwaa.data}},
 #' \code{\link{merge.snp.data}},

Modified: pkg/GenABEL/R/check.marker.R
===================================================================
--- pkg/GenABEL/R/check.marker.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/R/check.marker.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -1,7 +1,7 @@
 "check.marker" <-
 		function(data, snpsubset, idsubset,
 				callrate=0.95,perid.call=0.95, extr.call = 0.1, extr.perid.call = 0.1, 
-				het.fdr=0.01, ibs.threshold = 0.95, ibs.mrk = 2000, ibs.exclude="lower",
+				het.fdr=0.01, ibs.threshold = 0.95, ibs.mrk = 2000, ibs.exclude="both",
 				maf, p.level=-1, 
 				fdrate = 0.2, odds = 1000, hweidsubset, redundant="no", minconcordance = 2.0, 
 				qoption="bh95",imphetasmissing=TRUE,XXY.call=0.8, 
@@ -23,6 +23,14 @@
 	smap <- data at map
 	schr <- chromosome(data)
 	
+	possibleIbsExclude <- c("both","lower","none")
+	if (length(ibs.exclude) != 1) 
+		stop("length(ibs.exclude) <> 1")
+	if (!(ibs.exclude %in% possibleIbsExclude)) 
+		stop(paste("'ibs.exclude' should be one of",possibleIbsExclude))
+	if (ibs.exclude == "none") 
+		ibs.mrk = -1
+	
 	cat("Excluding people/markers with extremely low call rate...\n")
 	cat(nsnps(data),"markers and",nids(data),"people in total\n")
 	ts <- perid.summary(data)

Modified: pkg/GenABEL/R/polygenic.R
===================================================================
--- pkg/GenABEL/R/polygenic.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/R/polygenic.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -94,12 +94,14 @@
 #' heritability, (polygenic + residual variance)). The value of 
 #' twice negative maximum log-likelihood
 #' is returned as h2an\$minimum.}
+#' \item{esth2}{Estimate (or fixed value) of heritability}
 #' \item{residualY}{Residuals from analysis, based on covariate effects only; 
 #' NOTE: these are NOT grammar "environmental residuals"!}
-#' \item{esth2}{Estimate (or fixed value) of heritability}
 #' \item{pgresidualY}{Environmental residuals from analysis, based on covariate effects 
 #' and predicted breeding value.
 #' }
+#' \item{grresidualY}{GRAMMAR+ trait transformation}
+#' \item{grammarGamma}{list with GRAMMAR+ correction factors}
 #' \item{InvSigma}{Inverse of the variance-covariance matrix, computed at the 
 #' MLEs -- these are used in \code{\link{mmscore}} and \code{\link{grammar}}
 #' functions.}
@@ -121,6 +123,8 @@
 #' 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.
 #' 
+#' G. Svischeva et al. (in preparation)
+#' 
 #' @author Yurii Aulchenko, Gulnara Svischeva
 #' 
 #' @note 
@@ -280,7 +284,7 @@
 		eigres <- eigen(relmat,symm=TRUE)
 		if (any(eigres$values<0)) {
 			#eigres$values <- abs(eigres$values)
-			warning("some eigenvalues <=0, taking ABS for det; try option llfun='polylik'",immediate.=TRUE)
+			warning("some eigenvalues <=0, taking ABS for det; try option llfun='polylik'")
 		}
 	} else stop("cannot be here...")
 	if (!quiet) {
@@ -440,10 +444,10 @@
 	if (clafo == "formula") {
 		if (!missing(fixh2)) {fxeff <- h2an$est[1:(npar-1)]} else {fxeff <- h2an$est[1:(npar-2)]}
 		if (trait.type=="gaussian") {eY <- desmat %*% fxeff} else {ee <- exp(desmat %*% fxeff); eY <- ee/(1.+ee);}
-		out$residualY <- scay - eY
+		resY <- scay - eY
 	} else {
 		if (trait.type=="gaussian") {eY <- h2an$estimate[1]} else {ee <- exp(h2an$estimate[1]); eY <- ee/(1.+ee);}
-		out$residualY <- scay - eY
+		resY <- scay - eY
 	}
 	if (!missing(fixh2)) {
 		h2 <- fixh2
@@ -486,18 +490,40 @@
 # END new implementation of InvSigma
 	rownames(out$InvSigma) <- phids
 	colnames(out$InvSigma) <- phids
-	InvSigma_x_residualY <- (out$InvSigma %*% out$residualY)
-	pgres <- as.vector((1.-h2) * tvar * InvSigma_x_residualY)
 	out$measuredIDs <- mids
-# need to fix -- now only measured names, while length is >
-#	names(out$measuredIDs) <- phids
+# compute 'environmental' residuals for GRAMMAR-2007	
+	InvSigma_x_residualY <- (out$InvSigma %*% resY)
+	pgresY <- as.vector((1.-h2) * tvar * InvSigma_x_residualY)
 	out$pgresidualY <- rep(NA,length(mids))
-	out$pgresidualY[mids] <- pgres
+	out$pgresidualY[mids] <- pgresY
 	names(out$pgresidualY) <- allids #phids
-	resY <- out$residualY
+# compute residuals 	
 	out$residualY <- rep(NA,length(mids))
 	out$residualY[mids] <- resY
 	names(out$residualY) <- allids #phids
+	
+# compute GRAMMAR+ (G. Svischeva) residuals
+	zu <- mean(diag(out$InvSigma))*tvar
+	fi <- (1-(1-out$esth2)*zu)/(out$esth2 * tvar)
+	# 'eigen' is expensive operation -- can do faster???
+	eig <- eigen(out$InvSigma, symmetric = TRUE) 
+	# 'solve' is expensive operation -- can do faster???
+	# Bu <- t(eig$vectors) %*% diag(sqrt(eig$values)) %*% eig$vectors ???
+	Bu <- eig$vectors %*% diag(sqrt(eig$values)) %*% solve(eig$vectors)
+# GRAMMAR+ transformed outcome
+	grresY <- as.vector((1/sqrt(fi)) * (Bu %*% resY))
+	out$grresidualY <- rep(NA,length(mids))
+	out$grresidualY[mids] <- grresY
+	names(out$grresidualY) <- allids #phids
+# GRAMMAR+ correction coefficients
+	# VarYG1 <- (t(pgresY) %*% pgresY)/length(pgresY)
+	VarYG1 <- mean(pgresY^2)
+	z <- 1-(zu-1)*(1-out$esth2)/out$esth2
+	out$grammarGamma <- list()
+	out$grammarGamma$Beta <- z*(1-out$esth2)
+	out$grammarGamma$Test <- z*((1-out$esth2)^2)*tvar/VarYG1
+# END GRAMMAR+ computations
+
 	out$call <- match.call()
 	out$convFGLS <- convFGLS
 	

Modified: pkg/GenABEL/R/polygenic_hglm.R
===================================================================
--- pkg/GenABEL/R/polygenic_hglm.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/R/polygenic_hglm.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -76,8 +76,7 @@
 #' # ----- extract fixed effects estimates and standard errors
 #' h2ht$h2an
 #' 
-#' # test the significance of polygenic effect
-#' h2ht <- polygenic_hglm(height ~ sex + age, kin = gkin, df, method = 'REML')
+#' # ----- test the significance of polygenic effect
 #' nullht <- lm(height ~ sex + age, df)
 #' l1 <- h2ht$ProfLogLik
 #' l0 <- as.numeric(logLik(nullht))
@@ -90,7 +89,7 @@
 #' # p-value
 #' pchisq(S, 1, lower.tail = FALSE)/2
 #' 
-#' #' # ----- for binary traits
+#' # ----- for binary traits
 #' h2dm <- polygenic_hglm(dm2 ~ sex + age, kin = gkin, df, family = binomial(link = 'logit'))
 #' # ----- estimated parameters
 #' h2dm$h2an
@@ -98,39 +97,31 @@
 #' 
 #' @keywords htest
 #' 
-"polygenic_hglm" <- function(formula, kinship.matrix, data = NULL, 
-		family = gaussian(), conv = 1e-6, maxit = 100, ...)
+"polygenic_hglm" <- function(formula, kinship.matrix, data, family = gaussian(), conv = 1e-6, maxit = 100, ...)
 {
 	if (!require(hglm))
 		stop("this function requires 'hglm' package to be installed")
-	if (!is.null(data)) {
-		if (is(data,"gwaa.data")) 
+	if (!missing(data)) if (is(data,"gwaa.data")) 
 		{
 			checkphengen(data)
 			data <- phdata(data)
 		}
+	if (!missing(data)) 
 		if (!is(data,"data.frame")) 
 			stop("data should be of gwaa.data or data.frame class")
-	}
+	allids <- data$id
 	
 	relmat <- kinship.matrix
 	relmat[upper.tri(relmat)] <- t(relmat)[upper.tri(relmat)]
-	mf <- model.frame(formula,data,na.action=na.omit,drop.unused.levels=TRUE)
-	y <- model.response(mf)
-	desmat <- model.matrix(formula,mf)
 	
-	if (is.null(data)) {
-		if (!is.null(rownames(kinship.matrix))) {
-			allids <- rownames(kinship.matrix)
-		} else {
-			allids <- as.character(c(1:length(y)))
-			warning("no ID names identified, using integers")
-		}
-	} else {
-		allids <- data$id
-	}
+	call <- match.call()
+	if (inherits(try(length(formula), silent = TRUE), "try-error")) 
+		formula <- as.formula(paste(as.character(call)[2], '~ 1'))
 	
-	phids <- allids[allids %in% rownames(mf)]
+	mf <- model.frame(formula, data, na.action = na.omit, drop.unused.levels = TRUE)
+	y <- model.response(mf)
+	desmat <- model.matrix(formula, mf)
+	phids <- rownames(data)[rownames(data) %in% rownames(mf)]
 	mids <- (allids %in% phids)
 	relmat <- relmat[mids,mids]
 	relmat <- relmat*2.0
@@ -144,22 +135,29 @@
 	out$measuredIDs <- mids
 	out$hglm <- res_hglm
 	out$h2an <- list()
-	tVar <- res_hglm$varRan+res_hglm$varFix
+	tVar <- res_hglm$varRan + res_hglm$varFix
 	out$esth2 <- res_hglm$varRan/tVar
-	out$h2an$estimate <- c(res_hglm$fixef,out$esth2,tVar)
-	names(out$h2an$estimate)[(length(out$h2an$estimate)-1):(length(out$h2an$estimate))] <- 
+	out$h2an$estimate <- c(res_hglm$fixef,out$esth2, tVar)
+	names(out$h2an$estimate)[(length(out$h2an$estimate) - 1):(length(out$h2an$estimate))] <- 
 			c("h2","totalVar")
-	out$h2an$se <- c(res_hglm$SeFe,NA,NA)
+	out$h2an$se <- c(res_hglm$SeFe, NA, NA)
 	names(out$h2an$se) <- 
 			c(names(res_hglm$fixef), "h2","totalVar")
-	out$pgresidualY <- rep(NA,length(mids))
-	out$pgresidualY[mids] <- y-res_hglm$fv
-	out$residualY <- rep(NA,length(mids))
+	out$pgresidualY <- rep(NA, length(mids))
+	out$pgresidualY[mids] <- y - res_hglm$fv
+	out$residualY <- rep(NA, length(mids))
 	out$residualY[mids] <- y - desmat %*% res_hglm$fixef
-	out$InvSigma <- ginv(tVar*out$esth2*relmat + 
-					diag(tVar*(1-out$esth2),ncol=length(y),nrow=length(y)))
-	out$ProfLogLik <- res_hglm$ProfLogLik
+	Sigma <- tVar*out$esth2*relmat + diag(tVar*(1 - out$esth2), ncol = length(y), nrow = length(y))
+	out$InvSigma <- ginv(Sigma)
+	#out$InvSigma <- ginv(as.matrix(res_hglm$vcov))
+	#out$ProfLogLik <- res_hglm$ProfLogLik
 	
+	logdetSigma <- sum(log(eigen(Sigma, only.values = TRUE)$values))
+	temp <- determinant(t(desmat)%*%out$InvSigma%*%desmat, log = TRUE)
+	out$ProfLogLik <- as.numeric(- .5*logdetSigma 
+					- .5*t(out$residualY[mids])%*%out$InvSigma%*%out$residualY[mids]
+					- .5*temp$modulus*temp$sign)
+	
 	class(out) <- "polygenic"
 	out
 }

Modified: pkg/GenABEL/R/polylik.R
===================================================================
--- pkg/GenABEL/R/polylik.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/R/polylik.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -45,7 +45,7 @@
 	} else {
 		qt <- y - desmat %*% fixeff
 	}
-	y_0 <- as.vector(t(eigenRes$vectors) %*% qt)
+	y_0 <- as.vector(crossprod(eigenRes$vectors, qt))
 	eigenvalueCOV <- tvar*(eigenRes$values*h2+1.-h2)
 	loglik <- sum(log(abs(eigenvalueCOV))) + sum(y_0^2/eigenvalueCOV)
 	loglik

Added: pkg/GenABEL/R/recodeChromosome.R
===================================================================
--- pkg/GenABEL/R/recodeChromosome.R	                        (rev 0)
+++ pkg/GenABEL/R/recodeChromosome.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -0,0 +1,69 @@
+#' Change chromosomal coding
+#' 
+#' Recoding of chromosomes according to the provided 'rules' for from -> to 
+#' pairs. Most common use is anticipated when importing data from other 
+#' software using only integers to represent chromosomes. In this situation 
+#' the list of rules may look like this: list(24="X",25="Y",26="mt").
+#' 
+#' @note 'from' entries should be unique and not overlap with entries in 'to'
+#' 
+#' @param data object of class for which 'chromosome' method is defined, e.g. 
+#' 'gwaa.data', 'snp.data', 'scan.gwaa'
+#' 
+#' @param rules list of pairs 'from=to'; the chromosomes coded in the original data 
+#' set with 'from' will be recoded with 'to' value
+#' 
+#' @param quiet if summary of recoding should not be printed to the screen
+#' 
+#' @return modified 'data' object
+#' 
+#' @author Yurii Aulchenko
+#' 
+#' @examples 
+#' data(ge03d2)
+#' table(chromosome(ge03d2))
+#' # merge chromosome 3 and X, call chromosome 2 as 15
+#' newdat <- recodeChromosome(ge03d2,rules=list("3"="X","2"=15))
+#' table(chromosome(ge03d2),chromosome(newdat))
+#' 
+#' @keywords manip
+#' 
+#' 
+
+recodeChromosome <- function(data,rules,quiet=FALSE) 
+{
+	chrom <- try( chromosome ( data ) )
+	if (class(chrom) == "try-error") stop("'data' should have gwaa.data or snp.data class (1)")
+	if (class(rules) != "list") stop("'rules' should be a list")
+	if (anyDuplicated(names(rules))) stop("duplicated entries in 'rules' from-entries")
+	if (any( names(rules) %in% unlist(rules) )) stop("overlap in 'rules' between from and to entries")
+	for (fromName in names(rules)) {
+		toName <- rules[[fromName]]
+		print("aaa")
+		if (length(toName) != 1) 
+			stop(paste('rules list element with name',fromName,'has #entries <> 1'))
+		saveOpt <- getOption("warn")
+		options("warn" = -1)
+		if (!(toName == as.integer(toName) | toName %in% c("X","Y","mt") ) ) {
+			warning(paste("to-name",toName,"is neither integer nor one of 'X', 'Y', 'mt'"))
+		}
+		options("warn" = saveOpt)
+		print("bbb")
+		toBeRecoded <- which(chrom == as.character(fromName))
+		chrom[toBeRecoded] <- as.character(toName)
+		if (length(toBeRecoded) >= 1) {
+			cat("Recoded chromosome for",length(toBeRecoded),"SNPs (",fromName,"->",toName,")\n")
+		} else if (!quiet) {
+			cat("No chromosome coded as",fromName,"found\n")
+		}
+	}
+	if (class(data) == "gwaa.data") 
+		data at gtdata@chromosome <- as.factor(chrom)
+	else if (class(data) == "snp.data")
+		data at chromosome <- as.factor(chrom)
+	else if (class(data) == "scan.gwaa")
+		data at annotation[,"Chromosome"] <- as.factor(chrom)
+	else 
+		stop("'data' should have gwaa.data or snp.data class (2)")
+	return(data)
+}
\ No newline at end of file


Property changes on: pkg/GenABEL/R/recodeChromosome.R
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: pkg/GenABEL/R/ss.R
===================================================================
--- pkg/GenABEL/R/ss.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/R/ss.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -391,8 +391,11 @@
 			cod <- coding(object)
 			A1 <- substr(cod,1,1)
 			A2 <- substr(cod,2,2)
+#			res <- data.frame(Chromosome=chromosome(object),Position=map(object),
+#					Strand=strand(object),A1=A1,A2=A2,stringsAsFactors = FALSE)
+# should save space
 			res <- data.frame(Chromosome=chromosome(object),Position=map(object),
-					Strand=strand(object),A1=A1,A2=A2,stringsAsFactors = FALSE)
+					Strand=strand(object),A1=A1,A2=A2,stringsAsFactors = TRUE)
 			rownames(res) <- snpnames(object)
 			res
 		}
@@ -595,7 +598,9 @@
 		signature = "scan.gwaa",
 		definition = function(object) 
 		{
-			return(annotation(object)[,"Position"])
+			mp <- annotation(object)[,"Position"]
+			names(mp) <- snpnames(object)
+			return(mp)
 		}
 );
 
@@ -608,7 +613,9 @@
 		signature = "snp.data",
 		definition = function(object) 
 		{
-			return(as.character(object at chromosome))
+			chr <- as.character(object at chromosome)
+			names(chr) <- names(object at chromosome)
+			return(chr)
 		}
 );
 setMethod(
@@ -624,7 +631,9 @@
 		signature = "scan.gwaa",
 		definition = function(object) 
 		{
-			return(annotation(object)[,"Chromosome"])
+			chr <- as.character(annotation(object)[,"Chromosome"])
+			names(chr) <- snpnames(object) 
+			return(chr)
 		}
 );
 
@@ -688,7 +697,7 @@
 		}
 );
 
-# AAAA
+
 setGeneric(
 		name = "coding<-",
 		def = function(x,value) {standardGeneric("coding<-");}
@@ -720,7 +729,6 @@
 );
 
 
-
 setGeneric(
 		name = "refallele",
 		def = function(object) {standardGeneric("refallele");}

Modified: pkg/GenABEL/generate_documentation.R
===================================================================
--- pkg/GenABEL/generate_documentation.R	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/generate_documentation.R	2011-08-24 22:18:31 UTC (rev 769)
@@ -20,6 +20,7 @@
 		#"phdata.R",
 		"polygenic.R",
 		"polygenic_hglm.R",
+		"recodeChromosome.R",
 		"reconstructNPs.R",
 		"qtscore.R"
 		#,

Modified: pkg/GenABEL/inst/unitTests/report.html
===================================================================
--- pkg/GenABEL/inst/unitTests/report.html	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/inst/unitTests/report.html	2011-08-24 22:18:31 UTC (rev 769)
@@ -1,9 +1,9 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/transitional.dtd">
-<html><head><title>RUNIT TEST PROTOCOL--Fri Jul 15 19:22:57 2011</title>
+<html><head><title>RUNIT TEST PROTOCOL--Tue Aug 23 15:01:53 2011</title>
 </head>
-<body><h1 TRUE>RUNIT TEST PROTOCOL--Fri Jul 15 19:22:57 2011</h1>
-<p>Number of test functions: 11</p>
+<body><h1 TRUE>RUNIT TEST PROTOCOL--Tue Aug 23 15:01:53 2011</h1>
+<p>Number of test functions: 12</p>
 <p>Number of errors: 0</p>
 <p>Number of failures: 0</p>
 <hr>
@@ -15,7 +15,7 @@
 <th width="20%">Failures</th>
 </tr>
 <tr><td><a href="#GenABEL unit testing">GenABEL unit testing</a></td>
-<td>11</td>
+<td>12</td>
 <td>0</td>
 <td>0</td>
 </tr>
@@ -23,7 +23,7 @@
 <hr>
 <h3 TRUE>Details</h3>
 <p><a name="GenABEL unit testing"><h5 TRUE>Test Suite: GenABEL unit testing</h5>
-</a>Test function regexp: ^test.+<br/>Test file regexp: ^runit.+\.[rR]$<br/>Involved directory:<br/>/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests<br/><ul><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.R">Test file: runit.convert.snp.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.R_test.convert.snp">test.convert.snp: (4 checks) ... OK (0.86 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.ped.R">Test file: runit.convert.snp.ped.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.ped.R_test.convert.snp.ped">test.convert.snp.ped: (0 checks) ... OK (0.01 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.descriptives.trait.R">Test file: runit.descriptives.trait.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.descriptives.trait.R_test.descriptives.trait">test.descriptives.trait: (1 checks) ... OK (0.37 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.findRelatives.R">Test file: runit.findRelatives.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.findRelatives.R_test.findRelatives">test.findRelatives: (10 checks) ... OK (52.69 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx.R">Test file: runit.impute2xxx.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx.R_test.impute2databel">test.impute2databel: (23 checks) ... OK (0.38 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx_large.R">Test file: runit.impute2xxx_large.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx_large.R_test.impute2xxx_large">test.impute2xxx_large: (0 checks) ... OK (0 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.iterator.R">Test file: runit.iterator.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.qtscore">test.qtscore: (0 checks) ... OK (0 seconds)<br/></a></li><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.summary_snp_data">test.summary_snp_data: (3 checks) ... OK (4.05 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.mach2databel.R">Test file: runit.mach2databel.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.mach2databel.R_test.mach2databel">test.mach2databel: (8 checks) ... OK (0.13 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polygenic.R">Test file: runit.polygenic.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polygenic.R_test.polygenic.Bug1322">test.polygenic.Bug1322: (2 checks) ... OK (1.53 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polylik.R">Test file: runit.polylik.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polylik.R_test.polylik">test.polylik: (6 checks) ... OK (7.38 seconds)<br/></a></li></ul></li></ul><hr>
+</a>Test function regexp: ^test.+<br/>Test file regexp: ^runit.+\.[rR]$<br/>Involved directory:<br/>/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests<br/><ul><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.R">Test file: runit.convert.snp.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.R_test.convert.snp">test.convert.snp: (4 checks) ... OK (1.07 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.ped.R">Test file: runit.convert.snp.ped.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.ped.R_test.convert.snp.ped">test.convert.snp.ped: (0 checks) ... OK (0.02 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.descriptives.trait.R">Test file: runit.descriptives.trait.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.descriptives.trait.R_test.descriptives.trait">test.descriptives.trait: (1 checks) ... OK (0.4 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.findRelatives.R">Test file: runit.findRelatives.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.findRelatives.R_test.findRelatives">test.findRelatives: (10 checks) ... OK (53.27 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx.R">Test file: runit.impute2xxx.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx.R_test.impute2databel">test.impute2databel: (23 checks) ... OK (0.59 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx_large.R">Test file: runit.impute2xxx_large.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx_large.R_test.impute2xxx_large">test.impute2xxx_large: (0 checks) ... OK (0.02 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.iterator.R">Test file: runit.iterator.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.qtscore">test.qtscore: (0 checks) ... OK (0 seconds)<br/></a></li><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.summary_snp_data">test.summary_snp_data: (3 checks) ... OK (19.68 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.mach2databel.R">Test file: runit.mach2databel.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.mach2databel.R_test.mach2databel">test.mach2databel: (8 checks) ... OK (0.25 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polygenic.R">Test file: runit.polygenic.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polygenic.R_test.polygenic.Bug1322">test.polygenic.Bug1322: (2 checks) ... OK (1.68 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polylik.R">Test file: runit.polylik.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polylik.R_test.polylik">test.polylik: (6 checks) ... OK (7.86 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.recodeChromosome.R">Test file: runit.recodeChromosome.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.recodeChromosome.R_test.recodeChromosome">test.recodeChromosome: (8 checks) ... OK (0.2 seconds)<br/></a></li></ul></li></ul><hr>
 <table border="0" width="80%" >
 <tr><th>Name</th>
 <th>Value</th>

Modified: pkg/GenABEL/inst/unitTests/report.txt
===================================================================
--- pkg/GenABEL/inst/unitTests/report.txt	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/inst/unitTests/report.txt	2011-08-24 22:18:31 UTC (rev 769)
@@ -1,12 +1,12 @@
-RUNIT TEST PROTOCOL -- Fri Jul 15 19:22:57 2011 
+RUNIT TEST PROTOCOL -- Tue Aug 23 15:01:53 2011 
 *********************************************** 
-Number of test functions: 11 
+Number of test functions: 12 
 Number of errors: 0 
 Number of failures: 0 
 
  
 1 Test Suite : 
-GenABEL unit testing - 11 test functions, 0 errors, 0 failures
+GenABEL unit testing - 12 test functions, 0 errors, 0 failures
 
 
 
@@ -19,32 +19,35 @@
 /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests 
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.R 
-test.convert.snp: (4 checks) ... OK (0.86 seconds)
+test.convert.snp: (4 checks) ... OK (1.07 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.ped.R 
-test.convert.snp.ped: (0 checks) ... OK (0.01 seconds)
+test.convert.snp.ped: (0 checks) ... OK (0.02 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.descriptives.trait.R 
-test.descriptives.trait: (1 checks) ... OK (0.37 seconds)
+test.descriptives.trait: (1 checks) ... OK (0.4 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.findRelatives.R 
-test.findRelatives: (10 checks) ... OK (52.69 seconds)
+test.findRelatives: (10 checks) ... OK (53.27 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx.R 
-test.impute2databel: (23 checks) ... OK (0.38 seconds)
+test.impute2databel: (23 checks) ... OK (0.59 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx_large.R 
-test.impute2xxx_large: (0 checks) ... OK (0 seconds)
+test.impute2xxx_large: (0 checks) ... OK (0.02 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.iterator.R 
 test.qtscore: (0 checks) ... OK (0 seconds)
-test.summary_snp_data: (3 checks) ... OK (4.05 seconds)
+test.summary_snp_data: (3 checks) ... OK (19.68 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.mach2databel.R 
-test.mach2databel: (8 checks) ... OK (0.13 seconds)
+test.mach2databel: (8 checks) ... OK (0.25 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polygenic.R 
-test.polygenic.Bug1322: (2 checks) ... OK (1.53 seconds)
+test.polygenic.Bug1322: (2 checks) ... OK (1.68 seconds)
 --------------------------- 
 Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polylik.R 
-test.polylik: (6 checks) ... OK (7.38 seconds)
+test.polylik: (6 checks) ... OK (7.86 seconds)
+--------------------------- 
+Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.recodeChromosome.R 
+test.recodeChromosome: (8 checks) ... OK (0.2 seconds)

Modified: pkg/GenABEL/inst/unitTests/reportSummary.txt
===================================================================
--- pkg/GenABEL/inst/unitTests/reportSummary.txt	2011-08-24 13:41:14 UTC (rev 768)
+++ pkg/GenABEL/inst/unitTests/reportSummary.txt	2011-08-24 22:18:31 UTC (rev 769)
@@ -1,9 +1,9 @@
-RUNIT TEST PROTOCOL -- Fri Jul 15 19:22:57 2011 
+RUNIT TEST PROTOCOL -- Tue Aug 23 15:01:53 2011 
 *********************************************** 
-Number of test functions: 11 
+Number of test functions: 12 
 Number of errors: 0 
 Number of failures: 0 
 
  
 1 Test Suite : 
-GenABEL unit testing - 11 test functions, 0 errors, 0 failures
+GenABEL unit testing - 12 test functions, 0 errors, 0 failures

[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/genabel -r 769


More information about the Genabel-commits mailing list