From 1d5ab05fa8ae8b754feab62f41ab00a182d54793 Mon Sep 17 00:00:00 2001 From: Xiuwen Zheng Date: Sun, 12 Aug 2018 18:55:47 -0700 Subject: [PATCH] update seqGDS2SNP() with 'ds.type' --- DESCRIPTION | 4 ++-- R/Conversion.R | 5 +++-- README.md | 2 +- man/seqGDS2SNP.Rd | 5 ++++- src/ConvToGDS.cpp | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7e2972f..d39d0c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: SeqArray Type: Package Title: Big Data Management of Whole-genome Sequence Variant Calls -Version: 1.21.3 -Date: 2018-07-29 +Version: 1.21.4 +Date: 2018-08-12 Depends: R (>= 3.3.0), gdsfmt (>= 1.10.1) Imports: methods, parallel, IRanges, GenomicRanges, GenomeInfoDb, Biostrings, S4Vectors diff --git a/R/Conversion.R b/R/Conversion.R index b4c02aa..a4674a3 100644 --- a/R/Conversion.R +++ b/R/Conversion.R @@ -322,7 +322,7 @@ seqGDS2VCF <- function(gdsfile, vcf.fn, info.var=NULL, fmt.var=NULL, seqGDS2SNP <- function(gdsfile, out.gdsfn, dosage=FALSE, compress.geno="LZMA_RA", compress.annotation="LZMA_RA", - optimize=TRUE, verbose=TRUE) + ds.type=c("packedreal16", "float", "double"), optimize=TRUE, verbose=TRUE) { # check stopifnot(is.character(gdsfile) | inherits(gdsfile, "SeqVarGDSClass")) @@ -332,6 +332,7 @@ seqGDS2SNP <- function(gdsfile, out.gdsfn, dosage=FALSE, stopifnot(is.character(compress.annotation), length(compress.annotation)==1L) stopifnot(is.logical(optimize), length(optimize)==1L) stopifnot(is.logical(verbose), length(verbose)==1L) + ds.type <- match.arg(ds.type) if (verbose) { @@ -427,7 +428,7 @@ seqGDS2SNP <- function(gdsfile, out.gdsfn, dosage=FALSE, FUN = .cfunction("FC_GDS2SNP")) } else { .cfunction("FC_SetNumSamp")(length(sampid)) - gGeno <- add.gdsn(gfile, "genotype", storage="float32", + gGeno <- add.gdsn(gfile, "genotype", storage=ds.type, valdim=c(length(sampid), 0L), compress=compress.geno) put.attr.gdsn(gGeno, "sample.order") seqApply(gdsfile, dosage, as.is=gGeno, .progress=verbose, diff --git a/README.md b/README.md index de0bdee..c7249f7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Release Version: v1.20.1 * [Help Documents](http://zhengxwen.github.io/SeqArray/release/help/00Index.html) * Tutorials: [Data Management](http://www.bioconductor.org/packages/release/bioc/vignettes/SeqArray/inst/doc/SeqArrayTutorial.html), [R Integration](http://www.bioconductor.org/packages/release/bioc/vignettes/SeqArray/inst/doc/R_Integration.html), [Overview Slides](http://www.bioconductor.org/packages/release/bioc/vignettes/SeqArray/inst/doc/OverviewSlides.html) -Development Version: v1.21.2 +Development Version: v1.21.3 [http://www.bioconductor.org/packages/devel/bioc/html/SeqArray.html](http://www.bioconductor.org/packages/devel/bioc/html/SeqArray.html) diff --git a/man/seqGDS2SNP.Rd b/man/seqGDS2SNP.Rd index 70727e6..075dcef 100644 --- a/man/seqGDS2SNP.Rd +++ b/man/seqGDS2SNP.Rd @@ -6,7 +6,8 @@ } \usage{ seqGDS2SNP(gdsfile, out.gdsfn, dosage=FALSE, compress.geno="LZMA_RA", - compress.annotation="LZMA_RA", optimize=TRUE, verbose=TRUE) + compress.annotation="LZMA_RA", ds.type=c("packedreal16", "float", "double"), + optimize=TRUE, verbose=TRUE) } \arguments{ \item{gdsfile}{character (GDS file name), or @@ -20,6 +21,8 @@ seqGDS2SNP(gdsfile, out.gdsfn, dosage=FALSE, compress.geno="LZMA_RA", \item{compress.annotation}{the compression method for the GDS variables, except "genotype"; optional values are defined in the function \code{add.gdsn}} + \item{ds.type}{applicable when import dosages, the data type for storing + dosages; see \code{\link{add.gdsn}}} \item{optimize}{if \code{TRUE}, optimize the access efficiency by calling \code{\link{cleanup.gds}}} \item{verbose}{if \code{TRUE}, show information} diff --git a/src/ConvToGDS.cpp b/src/ConvToGDS.cpp index 0fc4829..32c8571 100755 --- a/src/ConvToGDS.cpp +++ b/src/ConvToGDS.cpp @@ -303,7 +303,7 @@ COREARRAY_DLL_EXPORT SEXP FC_SetNumSamp(SEXP num) COREARRAY_DLL_EXPORT SEXP FC_GDS2Dosage(SEXP dosage) { - int n = LENGTH(dosage); + int n = Rf_isNull(dosage) ? 0 : LENGTH(dosage); if (n < FC_Num_Sample) { dosage = NEW_NUMERIC(FC_Num_Sample);