From 96d693ef66600cafa38f737423e13ecb9767af30 Mon Sep 17 00:00:00 2001 From: Xiuwen Zheng Date: Wed, 18 May 2016 13:56:48 -0700 Subject: [PATCH] version bump --- DESCRIPTION | 6 ++--- NAMESPACE | 7 ++++++ NEWS | 8 ++++++ R/AllUtilities.R | 20 ++------------- README.md | 4 +-- man/snpgdsGetGeno.Rd | 9 ++++--- src/SNPRelate.cpp | 59 ++++++++++++++++++++++++++++++-------------- src/dGenGWAS.cpp | 11 ++++++--- 8 files changed, 74 insertions(+), 50 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cf3da8c..af57c03 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Package: SNPRelate Type: Package Title: Parallel Computing Toolset for Relatedness and Principal Component Analysis of SNP Data -Version: 1.5.2 -Date: 2016-02-23 +Version: 1.7.3 +Date: 2016-05-18 Depends: R (>= 2.14), gdsfmt (>= 1.6.2) LinkingTo: gdsfmt Suggests: parallel, RUnit, knitr, MASS, BiocGenerics @@ -30,7 +30,7 @@ Description: Genome-wide association studies (GWAS) are widely used to also used by the GWASTools package with the support of S4 classes and generic functions. The extended GDS format is implemented in the SeqArray package to support the storage of single nucleotide - variation (SNV), insertion/deletion polymorphism (indel) and + variations (SNVs), insertion/deletion polymorphism (indel) and structural variation calls. License: GPL-3 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 62202cd..6ff9303 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,3 +26,10 @@ export(.onAttach) # Import all packages listed as Imports or Depends import(gdsfmt) + +importFrom(grDevices, rgb) +importFrom(graphics, abline, axis, mtext, par, plot, rect, + text) +importFrom(stats, as.dendrogram, as.dist, dendrapply, hclust, + is.leaf, sd) +importFrom(utils, count.fields, read.table, write.table) diff --git a/NEWS b/NEWS index 2287448..fd632d2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +CHANGES IN VERSION 1.6.0 +------------------------- + + o the version number was bumped for the Bioconductor release version 3.3 + + CHANGES IN VERSION 1.5.0-1.5.2 ------------------------- @@ -5,6 +11,8 @@ CHANGES IN VERSION 1.5.0-1.5.2 o bug fix in `snpgdsPCASampLoading()` when the input is SeqArray GDS file + o improve `snpgdsGetGeno()` + CHANGES IN VERSION 1.4.0 ------------------------- diff --git a/R/AllUtilities.R b/R/AllUtilities.R index 33e5de3..51f85a7 100755 --- a/R/AllUtilities.R +++ b/R/AllUtilities.R @@ -972,7 +972,7 @@ snpgdsSummary <- function(gds, show=TRUE) # snpgdsGetGeno <- function(gdsobj, sample.id=NULL, snp.id=NULL, - snpfirstdim=NULL, with.id=FALSE, verbose=TRUE) + snpfirstdim=NA, .snpread=NA, with.id=FALSE, verbose=TRUE) { if (is.character(gdsobj)) { @@ -984,24 +984,8 @@ snpgdsGetGeno <- function(gdsobj, sample.id=NULL, snp.id=NULL, ws <- .InitFile(gdsobj, sample.id=sample.id, snp.id=snp.id, with.id=with.id) - # snp order - if (is.null(snpfirstdim)) - snpfirstdim <- .Call(gnrGetGenoDimInfo) - else - stopifnot(is.logical(snpfirstdim)) - - stopifnot(is.logical(verbose)) - if (verbose) - { - cat("Genotype matrix: ") - if (snpfirstdim) - cat(sprintf("%d SNPs X %d samples\n", ws$n.snp, ws$n.samp)) - else - cat(sprintf("%d samples X %d SNPs\n", ws$n.samp, ws$n.snp)) - } - # get genotypes - ans <- .Call(gnrCopyGenoMem, snpfirstdim) + ans <- .Call(gnrCopyGenoMem, snpfirstdim, .snpread, verbose) if (with.id) ans <- list(genotype=ans, sample.id=ws$sample.id, snp.id=ws$snp.id) diff --git a/README.md b/README.md index be8c177..5310fd9 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ The GDS format offers the efficient operations specifically designed for integer ## Bioconductor: -Release Version: v1.4.2 +Release Version: v1.6.2 [http://www.bioconductor.org/packages/release/bioc/html/SNPRelate.html](http://www.bioconductor.org/packages/release/bioc/html/SNPRelate.html) -Development Version: v1.5.2 +Development Version: v1.7.2 [http://www.bioconductor.org/packages/devel/bioc/html/SNPRelate.html](http://www.bioconductor.org/packages/devel/bioc/html/SNPRelate.html) diff --git a/man/snpgdsGetGeno.Rd b/man/snpgdsGetGeno.Rd index 5695ce4..af09dac 100644 --- a/man/snpgdsGetGeno.Rd +++ b/man/snpgdsGetGeno.Rd @@ -7,8 +7,8 @@ To get a genotype matrix from a specified GDS file } \usage{ -snpgdsGetGeno(gdsobj, sample.id=NULL, snp.id=NULL, snpfirstdim=NULL, - with.id=FALSE, verbose=TRUE) +snpgdsGetGeno(gdsobj, sample.id=NULL, snp.id=NULL, snpfirstdim=NA, + .snpread=NA, with.id=FALSE, verbose=TRUE) } \arguments{ \item{gdsobj}{an object of class \code{\link{SNPGDSFileClass}}, @@ -19,8 +19,9 @@ snpgdsGetGeno(gdsobj, sample.id=NULL, snp.id=NULL, snpfirstdim=NULL, if NULL, all SNPs are used} \item{snpfirstdim}{if \code{TRUE}, genotypes are stored in the individual-major mode, (i.e, list all SNPs for the first individual, - and then list all SNPs for the second individual, etc); if \code{NULL}, - determine automatically} + and then list all SNPs for the second individual, etc); \code{FALSE} + for snp-major mode; if \code{NA}, determine automatically} + \item{.snpread}{internal use} \item{with.id}{if \code{TRUE}, return \code{sample.id} and \code{snp.id}} \item{verbose}{if TRUE, show information} } diff --git a/src/SNPRelate.cpp b/src/SNPRelate.cpp index d0e6fde..14897bc 100755 --- a/src/SNPRelate.cpp +++ b/src/SNPRelate.cpp @@ -9,7 +9,7 @@ // SNPRelate.cpp: Relatedness, Linkage Disequilibrium and // Principal Component Analysis // -// Copyright (C) 2011 - 2015 Xiuwen Zheng [zhengxwen@gmail.com] +// Copyright (C) 2011 - 2016 Xiuwen Zheng [zhengxwen@gmail.com] // // This file is part of SNPRelate. // @@ -322,35 +322,56 @@ COREARRAY_DLL_EXPORT SEXP gnrCopyGeno(SEXP Node, SEXP snpfirstorder) /// copy genotypes to a memory buffer -COREARRAY_DLL_EXPORT SEXP gnrCopyGenoMem(SEXP snpfirstdim) +COREARRAY_DLL_EXPORT SEXP gnrCopyGenoMem(SEXP snpfirstdim, SEXP snpread, + SEXP verbose) { - int if_snp = Rf_asLogical(snpfirstdim); - if (if_snp == NA_LOGICAL) - error("'snpfirstdim' must be TRUE, FALSE or NULL."); + int snp_first = Rf_asLogical(snpfirstdim); + int snp_read = Rf_asLogical(snpread); + int _verbose = Rf_asLogical(verbose); COREARRAY_TRY CdBaseWorkSpace &Space = MCWorkingGeno.Space(); - if (if_snp) + + if (snp_first == NA_INTEGER) { - rv_ans = Rf_allocMatrix(INTSXP, Space.SNPNum(), Space.SampleNum()); - } else { - rv_ans = Rf_allocMatrix(INTSXP, Space.SampleNum(), Space.SNPNum()); + snp_first = (Space.GenoDimType() == RDim_SNP_X_Sample) ? + TRUE : FALSE; + } + if (snp_read == NA_INTEGER) + { + snp_read = (Space.GenoDimType() == RDim_Sample_X_SNP) ? + TRUE : FALSE; } - int *pMem = INTEGER(PROTECT(rv_ans)); - C_UInt8 *p8 = (C_UInt8*)pMem; - - // read data - if (Space.GenoDimType() == RDim_Sample_X_SNP) + if (snp_first) { - Space.snpRead(0, Space.SNPNum(), p8, - if_snp ? RDim_SNP_X_Sample : RDim_Sample_X_SNP); + rv_ans = PROTECT(Rf_allocMatrix(INTSXP, Space.SNPNum(), + Space.SampleNum())); + if (_verbose == TRUE) + { + Rprintf("Genotype matrix: %d SNPs X %d samples\n", + Space.SNPNum(), Space.SampleNum()); + } } else { - Space.sampleRead(0, Space.SampleNum(), p8, - if_snp ? RDim_SNP_X_Sample : RDim_Sample_X_SNP); + rv_ans = PROTECT(Rf_allocMatrix(INTSXP, Space.SampleNum(), + Space.SNPNum())); + if (_verbose == TRUE) + { + Rprintf("Genotype matrix: %d samples X %d SNPs\n", + Space.SampleNum(), Space.SNPNum()); + } } + int *pMem = INTEGER(rv_ans); + C_UInt8 *p8 = (C_UInt8*)pMem; + + TTypeGenoDim dir = snp_first ? RDim_SNP_X_Sample : RDim_Sample_X_SNP; + if (snp_read) + Space.snpRead(0, Space.SNPNum(), p8, dir); + else + Space.sampleRead(0, Space.SampleNum(), p8, dir); + size_t n = XLENGTH(rv_ans); pMem += n; p8 += n; for (; n > 0; n--) @@ -1210,7 +1231,7 @@ COREARRAY_DLL_EXPORT void R_init_SNPRelate(DllInfo *info) CALL(gnrParseGEN, 9), CALL(gnrParsePED, 8), CALL(gnrParseVCF4Init, 0), CALL(gnrParseVCF4, 10), - CALL(gnrCopyGeno, 2), CALL(gnrCopyGenoMem, 1), + CALL(gnrCopyGeno, 2), CALL(gnrCopyGenoMem, 3), CALL(gnrGetGenoDim, 0), CALL(gnrGetGenoDimInfo, 0), CALL(gnrSetGenoSpace, 3), CALL(gnrSetSeqSpace, 3), diff --git a/src/dGenGWAS.cpp b/src/dGenGWAS.cpp index b338175..9f1999e 100755 --- a/src/dGenGWAS.cpp +++ b/src/dGenGWAS.cpp @@ -1795,12 +1795,15 @@ bool GWAS::SEXP_Verbose(SEXP Verbose) void GWAS::CachingSNPData(const char *Msg, bool Verbose) { - double SumOfGenotype = MCWorkingGeno.Space().SumOfGenotype(); - if (Verbose) + if (dynamic_cast(&MCWorkingGeno.Space())) { - Rprintf( - "%s:\tthe sum of all working genotypes (0, 1 and 2) = %.0f\n", + double SumOfGenotype = MCWorkingGeno.Space().SumOfGenotype(); + if (Verbose) + { + Rprintf( + "%s:\tthe sum of all working genotypes (0, 1 and 2) = %.0f\n", Msg, SumOfGenotype); + } } }