[Genabel-commits] r814 - in pkg/GenABEL: . R inst/unitTests man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Dec 6 02:21:52 CET 2011
Author: yurii
Date: 2011-12-06 02:21:51 +0100 (Tue, 06 Dec 2011)
New Revision: 814
Added:
pkg/GenABEL/R/checkPackageVersionOnCRAN.R
pkg/GenABEL/man/checkPackageVersionOnCRAN.Rd
pkg/GenABEL/man/sortmap.internal.Rd
Modified:
pkg/GenABEL/CHANGES.LOG
pkg/GenABEL/NAMESPACE
pkg/GenABEL/R/export.plink.R
pkg/GenABEL/R/sortmap.internal.R
pkg/GenABEL/R/zUtil.R
pkg/GenABEL/R/zzz.R
pkg/GenABEL/generate_documentation.R
pkg/GenABEL/inst/unitTests/runit.sortmap.internal.R
pkg/GenABEL/man/export.plink.Rd
pkg/GenABEL/man/polygenic.Rd
Log:
Addressed bug [#1383] (message about upgrade on loading the library not entirely correct) by adding new function checkPackageVersionOnCRAN() and re-writing zzz.R using it.
Modified: pkg/GenABEL/CHANGES.LOG
===================================================================
--- pkg/GenABEL/CHANGES.LOG 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/CHANGES.LOG 2011-12-06 01:21:51 UTC (rev 814)
@@ -1,5 +1,9 @@
-*** v. 1.7-0 (2011.11.15)
+*** v. 1.7-0 (2011.12.05)
+Addressed bug [#1383] (message about upgrade on loading the library
+not entirely correct) by adding new function checkPackageVersionOnCRAN()
+and re-writing zzz.R using it.
+
Addressed bug [#1673] (bug in load.gwaa.data and export.merlin when
sorting is enabled, filed in by Daniel Taliun), added unit test
runit.sortmap.internal.R/test.sortmap.internal.bug1673
Modified: pkg/GenABEL/NAMESPACE
===================================================================
--- pkg/GenABEL/NAMESPACE 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/NAMESPACE 2011-12-06 01:21:51 UTC (rev 814)
@@ -25,6 +25,7 @@
blurGenotype,
catable,
ccfast,
+ checkPackageVersionOnCRAN,
check.marker,
check.trait,
cocohet,
@@ -102,6 +103,7 @@
snp.data,
snp.names,
snp.subset,
+ sortmap.internal,
sset,
strand,
summary.check.marker,
Added: pkg/GenABEL/R/checkPackageVersionOnCRAN.R
===================================================================
--- pkg/GenABEL/R/checkPackageVersionOnCRAN.R (rev 0)
+++ pkg/GenABEL/R/checkPackageVersionOnCRAN.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -0,0 +1,59 @@
+#' checks what is the version of package on CRAN
+#'
+#' Checks what is the version of package on CRAN.
+#' The CRAN page (baseUrlCRAN+packageName) is checked
+#' and parsed extracting the line with
+#' "Package source: packageName_Version.tar.gz"
+#' e.g.
+#' "Package source: GenABEL_1.6-9.tar.gz"
+#' and then the 'Version' is returned.
+#' Otherwise, NULL is returned.
+#'
+#' @return string containing CRAN version
+#' of the package
+#'
+#' @param packageName name of the package to check
+#' @param baseUrlCRAN path to CRAN repository
+#' @param timeout web chack timeout
+#'
+#' @examples
+#' library(GenABEL)
+#' packageVersion("GenABEL")
+#' checkPackageVersionOnCRAN("GenABEL")
+#'
+#' @author Yurii Aulchenko
+#'
+checkPackageVersionOnCRAN <- function(packageName,baseUrlCRAN="http://cran.r-project.org/web/packages/", timeout = 10)
+{
+ # change default timout
+ svtmo <- options("timeout")
+ options("timeout"=timeout)
+ # page to check is
+ pageAddress <- paste(baseUrlCRAN,packageName,sep="/")
+ # establish connection to the CRAN page of the package
+ suppressWarnings(
+ conn <- try( url(pageAddress) , silent=TRUE )
+ )
+ # if connection ok, read full page, store the results in pageContent; if failed, pageContent <- "try-error"
+ if ( all( class(conn) != "try-error") ) {
+ suppressWarnings(
+ pageContent <- try( readLines(conn) , silent=TRUE )
+ )
+ close(conn)
+ } else {
+ pageContent <- "try-error"
+ class(pageContent) <- "try-error"
+ }
+ # restore default timeout
+ options("timeout"=svtmo)
+ # if failed in reading (pageContent is "try-error"), return NULL
+ if (class(pageContent) == "try-error") return(NULL)
+ # parse the page and get string starting with "Package source:"
+ targetLine <- pageContent[grep("Package source:",pageContent)]
+ # split the string at "Package_" and ".tar.gz"; the element before the last will contain the version
+ splitPattern <- paste(packageName,"_|.tar.gz",sep="")
+ stringSplit <- strsplit(targetLine,splitPattern)
+ cranVersion <- stringSplit[[1]][length(stringSplit[[1]])-1]
+ # return version
+ return(cranVersion)
+}
Property changes on: pkg/GenABEL/R/checkPackageVersionOnCRAN.R
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: pkg/GenABEL/R/export.plink.R
===================================================================
--- pkg/GenABEL/R/export.plink.R 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/R/export.plink.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -16,6 +16,12 @@
#' all phenotypes or a vector of character with names of phneotypes
#' to be exported
#'
+#' @param transpose if FALSE, regular 'tped' files produced, else
+#' 'ped' files are produced
+#'
+#' @param export012na if true, export in numeric (0, 1, 2, NA) format
+#' (as opposed to ATGC format)
+#'
#' @param ... arguments passed to \code{\link{export.merlin}}
#'
#' @author Yurii Aulchenko
Modified: pkg/GenABEL/R/sortmap.internal.R
===================================================================
--- pkg/GenABEL/R/sortmap.internal.R 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/R/sortmap.internal.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -1,3 +1,17 @@
+#' Internal function for map-sorting
+#'
+#' Internal function for map-sorting, not supposed
+#' to be used directly by user (is open for regression
+#' testing reasons)
+#'
+#' @param chrom vector of markers' chromosomes
+#' @param map vector of marlers' map ositions
+#' @param delta step to do between chroms when building cumulative map
+#'
+#' @return list, withe elements 'ix' ('sorted' order), etc.
+#'
+#' @author Yurii Aulchenko
+#'
"sortmap.internal" <-
function(chrom,map,delta=1) {
chnum <- chrom.char2num(chrom)
@@ -16,23 +30,4 @@
out$cummap <- cummap
out$chnum <- chnum
out
-}
-
-chrom.char2num <- function(chrom) {
- chrom <- as.character(chrom)
- chdesU <- unique(chrom)
- chnumU <- suppressWarnings(as.numeric(chdesU))
- chCHU <- sort(chdesU[is.na(chnumU)])
- if (any(!is.na(chnumU))) {
- maxch <- max(chnumU,na.rm=T)
- } else {
- maxch <- 0
- }
- j <- 1
- for (i in chCHU) {
- chrom[which(chrom==i)] <- as.character(maxch+j)
- j <- j + 1
- }
- chnum <- as.numeric(chrom)
- chnum
-}
+}
\ No newline at end of file
Modified: pkg/GenABEL/R/zUtil.R
===================================================================
--- pkg/GenABEL/R/zUtil.R 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/R/zUtil.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -8,3 +8,21 @@
optRes <- optimize(lossFunctionLambdaKS, interval=limits, chi2values=chi2values, "pchisq", 1)
return(optRes$minimum)
}
+chrom.char2num <- function(chrom) {
+ chrom <- as.character(chrom)
+ chdesU <- unique(chrom)
+ chnumU <- suppressWarnings(as.numeric(chdesU))
+ chCHU <- sort(chdesU[is.na(chnumU)])
+ if (any(!is.na(chnumU))) {
+ maxch <- max(chnumU,na.rm=T)
+ } else {
+ maxch <- 0
+ }
+ j <- 1
+ for (i in chCHU) {
+ chrom[which(chrom==i)] <- as.character(maxch+j)
+ j <- j + 1
+ }
+ chnum <- as.numeric(chrom)
+ chnum
+}
Modified: pkg/GenABEL/R/zzz.R
===================================================================
--- pkg/GenABEL/R/zzz.R 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/R/zzz.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -1,8 +1,20 @@
.onLoad <- function(lib, pkg) {
- GenABEL.version <- "1.7-0"
- cat("GenABEL v.",GenABEL.version,"(December 05, 2011) loaded\n")
-
- # check for updates and news
+ pkgDescription <- packageDescription(pkg)
+ pkgVersion <- pkgDescription$Version
+ pkgDate <- pkgDescription$Date
+ welcomeMessage <- paste(pkg," v. ",pkgVersion," (",pkgDate,") loaded\n",sep="")
+ # check if CRAN version is the same as loaded
+ cranVersion <- checkPackageVersionOnCRAN(pkg)
+ if (!is.null(cranVersion))
+ if (pkgVersion != cranVersion) {
+ welcomeMessage <- paste(welcomeMessage,
+ "\nInstalled ",pkg," version (",pkgVersion,") is not the same as stable\n",
+ "version available from CRAN (",cranVersion,"). Unless used intentionally,\n",
+ "consider updating to the latest CRAN version. For that, use\n",
+ "'install.packages(\"",pkg,"\")', or ask your system administrator\n",
+ "to update the package.\n\n",sep="")
+ }
+ # check for news
address <- c(
"http://genabel.r-forge.r-project.org/version_and_news.html",
"http://www.genabel.org/sites/default/files/version_and_news.html"
@@ -24,38 +36,25 @@
if (class(tryRes1) != "try-error") {
if (length(fulltext)>0)
{
- a <- tolower(fulltext)
- a <- a[grep("<gastable>",a)+1]
- if (length(a)>0) {
- # message to all users
- strnews <- grep("<messagetoall>",tolower(fulltext))
- endnews <- grep("</messagetoall>",tolower(fulltext))
- if (length(strnews)>0 && length(endnews)>0)
- if ((endnews-1) >= (strnews+1)) {
- cat(fulltext[(strnews+1):(endnews-1)],sep="\n")
- }
- # compare versions
- a <- strsplit(a,"")[[1]]
- ver <- a[grep("[0-9]",a)]
- ver <- paste(ver[1],".",ver[2],"-",ver[3],sep="")
- if (GenABEL.version != ver) {
- cat( "\nInstalled GenABEL version (",GenABEL.version,") is not the same as stable\n",
- "version available from CRAN (",ver,"). Unless used intentionally,\n",
- "consider updating to the latest CRAN version. For that, use\n",
- "'install.packages(\"GenABEL\")', or ask your system administrator\n",
- "to update the package.\n\n",sep="")
- # check for new-version news
- strnews <- grep("<ganews>",tolower(fulltext))
- endnews <- grep("</ganews>",tolower(fulltext))
- if (length(strnews)>0 && length(endnews)>0)
- if ((endnews-1) >= (strnews+1)) {
- cat(fulltext[(strnews+1):(endnews-1)],sep="\n")
- }
+ # message to all users
+ strnews <- grep("<messagetoall>",tolower(fulltext))
+ endnews <- grep("</messagetoall>",tolower(fulltext))
+ if (length(strnews)>0 && length(endnews)>0)
+ if ((endnews-1) >= (strnews+1)) {
+ welcomeMessage <- paste(welcomeMessage,
+ fulltext[(strnews+1):(endnews-1)],sep="\n")
}
- }
+ # check for specific package news
+ strnews <- grep(paste("<",pkg,"news>",sep=""),tolower(fulltext))
+ endnews <- grep(paste("</",pkg,"news>",sep=""),tolower(fulltext))
+ if (length(strnews)>0 && length(endnews)>0)
+ if ((endnews-1) >= (strnews+1)) {
+ welcomeMessage <- paste(welcomeMessage,
+ fulltext[(strnews+1):(endnews-1)],sep="\n")
+ }
}
#rm(a,fulltext,ver)
}
options("timeout"=svtmo)
- #rm(tryRes0,tryRes1,conn,svtmo)
+ packageStartupMessage(welcomeMessage)
}
Modified: pkg/GenABEL/generate_documentation.R
===================================================================
--- pkg/GenABEL/generate_documentation.R 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/generate_documentation.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -3,6 +3,7 @@
#"annotation",
"arrange_probabel_phe.R",
"blurGenotype.R",
+ "checkPackageVersionOnCRAN.R",
"del.phdata.R",
"estlambda.R",
"export.plink.R",
@@ -23,6 +24,7 @@
"polygenic_hglm.R",
"recodeChromosome.R",
"reconstructNPs.R",
+ "sortmap.internal.R",
"qtscore.R"
#,
#"summary.scan.gwaa.R"
Modified: pkg/GenABEL/inst/unitTests/runit.sortmap.internal.R
===================================================================
--- pkg/GenABEL/inst/unitTests/runit.sortmap.internal.R 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/inst/unitTests/runit.sortmap.internal.R 2011-12-06 01:21:51 UTC (rev 814)
@@ -22,7 +22,6 @@
test.sortmap.internal.bug1673 <- function()
{
- source("../R/sortmap.internal.R")
nmrkInChr <- c(7,5,3)
chrLevels <- c("cH1","X","Y")
chroms <- mappos <- rep(NA,sum(nmrkInChr))
Added: pkg/GenABEL/man/checkPackageVersionOnCRAN.Rd
===================================================================
--- pkg/GenABEL/man/checkPackageVersionOnCRAN.Rd (rev 0)
+++ pkg/GenABEL/man/checkPackageVersionOnCRAN.Rd 2011-12-06 01:21:51 UTC (rev 814)
@@ -0,0 +1,23 @@
+\name{checkPackageVersionOnCRAN}
+\alias{checkPackageVersionOnCRAN}
+\title{checks what is the version of package on CRAN...}
+\usage{checkPackageVersionOnCRAN(packageName,
+ baseUrlCRAN="http://cran.r-project.org/web/packages/", timeout=10)}
+\description{checks what is the version of package on CRAN}
+\details{Checks what is the version of package on CRAN.
+The CRAN page (baseUrlCRAN+packageName) is checked
+and parsed extracting the line with
+"Package source: packageName_Version.tar.gz"
+e.g.
+"Package source: GenABEL_1.6-9.tar.gz"
+and then the 'Version' is returned.
+Otherwise, NULL is returned.}
+\value{string containing CRAN version
+of the package}
+\author{Yurii Aulchenko}
+\arguments{\item{packageName}{name of the package to check}
+\item{baseUrlCRAN}{path to CRAN repository}
+\item{timeout}{web chack timeout}}
+\examples{library(GenABEL)
+packageVersion("GenABEL")
+checkPackageVersionOnCRAN("GenABEL")}
Property changes on: pkg/GenABEL/man/checkPackageVersionOnCRAN.Rd
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: pkg/GenABEL/man/export.plink.Rd
===================================================================
--- pkg/GenABEL/man/export.plink.Rd 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/man/export.plink.Rd 2011-12-06 01:21:51 UTC (rev 814)
@@ -18,4 +18,8 @@
\item{phenotypes}{NULL (no phenotypes exported), "all" for
all phenotypes or a vector of character with names of phneotypes
to be exported}
+\item{transpose}{if FALSE, regular 'tped' files produced, else
+'ped' files are produced}
+\item{export012na}{if true, export in numeric (0, 1, 2, NA) format
+(as opposed to ATGC format)}
\item{...}{arguments passed to \code{\link{export.merlin}}}}
Modified: pkg/GenABEL/man/polygenic.Rd
===================================================================
--- pkg/GenABEL/man/polygenic.Rd 2011-12-05 16:23:11 UTC (rev 813)
+++ pkg/GenABEL/man/polygenic.Rd 2011-12-06 01:21:51 UTC (rev 814)
@@ -9,9 +9,9 @@
\description{Estimation of polygenic model}
\details{This function maximises the likelihood of the data under polygenic
model with covariates an reports twice negative maximum likelihood estimates
-and the inverse of variance-covariance matrix at the point of ML.
+and the inverse of the variance-covariance matrix at the point of ML.
-One of the major use of this function is to estimate residuals of the
+One of the major uses of this function is to estimate residuals of the
trait and the inverse of the variance-covariance matrix for
further use in analysis with \code{\link{mmscore}} and
\code{\link{grammar}}.
@@ -24,7 +24,7 @@
the residual where both the effect of covariates AND the estimated
polygenic effect (breeding values) are factored out. This thus
provides an estimate of the trait value contributed by environment
-(or, turning this other way around, the part of trait not explained
+(or, turning this other way around, the part of the trait not explained
by covariates and by the polygene). Polygenic residuals are estimated
as
@@ -42,14 +42,14 @@
It can also be used for heritability analysis.
If you want to test significance of heritability,
estimate the model and write down
-the function minimum reported at "h2an" element of the output
-(this is twice negative MaxLikleihood). Then do next round of
-estimation, but set fixh2=0. The difference between you function minima
-gives a test distribued as chi-squared with 1 d.f.
+the function minimum reported at the "h2an" element of the output
+(this is twice the negative MaxLikelihood). Then do a next round of
+estimation, but set fixh2=0. The difference between your function minima
+gives a test distributed as chi-squared with 1 d.f.
-The way to compute the likleihood is partly based on
+The way to compute the likelihood is partly based on
the paper of Thompson (see refs), namely instead of
-taking inverse of var-cov matrix every time,
+taking the inverse of the var-cov matrix every time,
eigenvectors of the inverse of G (taken only once)
are used.}
\value{A list with values
@@ -87,23 +87,24 @@
G. Svischeva et al. (in preparation)}
\author{Yurii Aulchenko, Gulnara Svischeva}
-\note{Presence of twins may complicate your analysis. Check kinship matrix for
+\note{Presence of twins may complicate your analysis. Check the kinship matrix for
singularities, or rather use \code{\link{check.marker}} for identification
of twin samples. Take special care in interpretation.
-If a trait (no covarites) is used, make sure that order of IDs in
+If a trait (no covariates) is used, make sure that the order of IDs in the
kinship.matrix is exactly the same as in the outcome
Please note that there is alternative to 'polygenic',
\code{\link{polygenic_hglm}}, which is faster than
-'polygenic'.}
+polygenic() with the llfun='polylik' option, but slightly slower than the
+default polygenic().}
\seealso{\code{\link{polygenic_hglm}},
\code{\link{mmscore}},
\code{\link{grammar}}}
\keyword{htest}
-\arguments{\item{formula}{Formula describing fixed effects to be used in analysis, e.g.
+\arguments{\item{formula}{Formula describing fixed effects to be used in the analysis, e.g.
y ~ a + b means that outcome (y) depends on two covariates, a and b.
-If no covariates used in analysis, skip the right-hand side of the
+If no covariates used in the analysis, skip the right-hand side of the
equation.}
\item{kinship.matrix}{Kinship matrix, as provided by e.g. ibs(,weight="freq"),
or estimated outside of GenABEL from pedigree data.}
@@ -115,12 +116,12 @@
rest of MLEs and var.-cov. matrix.}
\item{starth2}{Starting value for h2 estimate}
\item{trait.type}{"gaussian" or "binomial"}
-\item{opt.method}{"nlm" or "optim". These two use dirrerent optimisation functions.
-We suggest using the default \code{\link{nlm}}, though
+\item{opt.method}{"nlm" or "optim". These two use different optimisation functions.
+We suggest using the default \code{\link{nlm}}, although
\code{\link{optim}} may give better results in some situations}
\item{scaleh2}{Only relevant when "nlm" optimisation function is used.
"scaleh2" is the heritability
-scaling parameter, regulating how "big" are parameter changes in h2 with the
+scaling parameter, regulating how "big" are parameter changes in h2 with
respect to changes in other parameters. As other parameters are estimated
from previous regression, these are expected to change little from the
initial estimate. The default value of 1000 proved to work rather well under a
@@ -129,20 +130,20 @@
\item{steptol}{steptal parameter of "nlm"}
\item{gradtol}{gradtol parameter of "nlm"}
\item{optimbou}{fixed effects boundary scale parameter for 'optim'}
-\item{fglschecks}{additional check for convergance on/off (convergence
+\item{fglschecks}{additional check for convergence on/off (convergence
between estimates obtained and that from FGLS)}
\item{maxnfgls}{number of fgls checks to perform}
\item{maxdiffgls}{max difference allowed in fgls checks}
\item{patchBasedOnFGLS}{if FGLS checks not passed, 'patch' fixed
effect estimates based on FGLS expectation}
\item{llfun}{function to compute likelihood (default 'polylik_eigen', also
-avalable -- but not recommeneded -- 'polylik')}
+available -- but not recommended -- 'polylik')}
\item{...}{Optional arguments to be passed to \code{\link{nlm}} or (\code{\link{optim}})
minimisation function}}
\examples{# note that procedure runs on CLEAN data
data(ge03d2ex.clean)
gkin <- ibs(ge03d2ex.clean,w="freq")
-h2ht <- polygenic(height ~ sex + age,kin=gkin,ge03d2ex.clean)
+h2ht <- polygenic(height ~ sex + age, kin=gkin, ge03d2ex.clean)
# estimate of heritability
h2ht$esth2
# other parameters
@@ -152,7 +153,7 @@
# twice maximum log-likelihood
-h2ht$h2an$minimum
-#for binary trait (experimental)
-h2dm <- polygenic(dm2 ~ sex + age,kin=gkin,ge03d2ex.clean,trait="binomial")
+# for binary trait (experimental)
+h2dm <- polygenic(dm2 ~ sex + age, kin=gkin, ge03d2ex.clean, trait="binomial")
# estimated parameters
h2dm$h2an}
Added: pkg/GenABEL/man/sortmap.internal.Rd
===================================================================
--- pkg/GenABEL/man/sortmap.internal.Rd (rev 0)
+++ pkg/GenABEL/man/sortmap.internal.Rd 2011-12-06 01:21:51 UTC (rev 814)
@@ -0,0 +1,13 @@
+\name{sortmap.internal}
+\alias{sortmap.internal}
+\title{Internal function for map-sorting...}
+\usage{sortmap.internal(chrom, map, delta=1)}
+\description{Internal function for map-sorting}
+\details{Internal function for map-sorting, not supposed
+to be used directly by user (is open for regression
+testing reasons)}
+\value{list, withe elements 'ix' ('sorted' order), etc.}
+\author{Yurii Aulchenko}
+\arguments{\item{chrom}{vector of markers' chromosomes}
+\item{map}{vector of marlers' map ositions}
+\item{delta}{step to do between chroms when building cumulative map}}
Property changes on: pkg/GenABEL/man/sortmap.internal.Rd
___________________________________________________________________
Added: svn:mime-type
+ text/plain
More information about the Genabel-commits
mailing list