Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengxwen committed May 18, 2016
1 parent 1a72a31 commit 96d693e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 50 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
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
-------------------------

o fix an issue in `snpgdsVCF2GDS()` if sample.id has white space

o bug fix in `snpgdsPCASampLoading()` when the input is SeqArray GDS file

o improve `snpgdsGetGeno()`


CHANGES IN VERSION 1.4.0
-------------------------
Expand Down
20 changes: 2 additions & 18 deletions R/AllUtilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions man/snpgdsGetGeno.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand All @@ -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}
}
Expand Down
59 changes: 40 additions & 19 deletions src/SNPRelate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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--)
Expand Down Expand Up @@ -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),
Expand Down
11 changes: 7 additions & 4 deletions src/dGenGWAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CdSNPWorkSpace*>(&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);
}
}
}

Expand Down

0 comments on commit 96d693e

Please sign in to comment.