Skip to content

Commit f69e001

Browse files
committed
compatible with SeqVarTools
1 parent ec4e405 commit f69e001

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: SeqArray
22
Type: Package
33
Title: Big Data Management of Whole-genome Sequence Variant Calls
4-
Version: 1.11.16
5-
Date: 2016-03-24
4+
Version: 1.11.17
5+
Date: 2016-03-25
66
Depends: R (>= 2.15.0), gdsfmt (>= 1.7.15)
77
Imports: methods, S4Vectors, IRanges, GenomicRanges,
88
SummarizedExperiment, Biostrings, VariantAnnotation

src/GetData.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,23 @@ COREARRAY_DLL_EXPORT SEXP SEQ_GetData(SEXP gdsfile, SEXP var_name, SEXP UseRaw)
408408
SET_STRING_ELT(tmp, 0, mkChar("length"));
409409
SET_STRING_ELT(tmp, 1, mkChar("data"));
410410
SET_NAMES(rv_ans, tmp);
411+
if (XLENGTH(DAT) > 0)
412+
{
413+
SEXP name_list = PROTECT(NEW_LIST(ndim));
414+
tmp = PROTECT(NEW_CHARACTER(ndim));
415+
if (ndim == 2)
416+
{
417+
SET_STRING_ELT(tmp, 0, mkChar("sample"));
418+
SET_STRING_ELT(tmp, 1, mkChar("variant"));
419+
} else {
420+
SET_STRING_ELT(tmp, 0, mkChar("n"));
421+
SET_STRING_ELT(tmp, 1, mkChar("sample"));
422+
SET_STRING_ELT(tmp, 2, mkChar("variant"));
423+
}
424+
SET_NAMES(name_list, tmp);
425+
SET_DIMNAMES(VECTOR_ELT(rv_ans, 1), name_list);
426+
UNPROTECT(2);
427+
}
411428
UNPROTECT(3);
412429

413430
} else if (strncmp(name, "sample.annotation/", 18) == 0)

src/ReadByVariant.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ SEXP CVarApplyByVariant::NeedRData(int &nProtected)
489489
p = INTEGER(dim = NEW_INTEGER(2));
490490
p[0] = DLen[2]; p[1] = Num_Sample;
491491
SET_DIM(ans, dim);
492+
{
493+
SEXP name_list = PROTECT(NEW_LIST(2));
494+
SEXP tmp = PROTECT(NEW_CHARACTER(2));
495+
SET_STRING_ELT(tmp, 0, mkChar("allele"));
496+
SET_STRING_ELT(tmp, 1, mkChar("sample"));
497+
SET_NAMES(name_list, tmp);
498+
SET_DIMNAMES(ans, name_list);
499+
UNPROTECT(2);
500+
}
492501
break;
493502

494503
case ctPhase:

vignettes/SeqArrayTutorial.Rmd

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ genofile <- seqOpen("tmp.gds", readonly=FALSE)
240240
genofile
241241
242242
# delete "HM2", "HM3", "AA", "OR" and "DP"
243-
seqDelete(genofile, info.varname=c("HM2", "HM3", "AA", "OR"),
244-
format.varname="DP")
243+
seqDelete(genofile, info.varname=c("HM2", "HM3", "AA", "OR"), format.varname="DP")
245244
246245
# display
247246
genofile
@@ -389,7 +388,7 @@ seqApply(genofile, c(geno="genotype", id="annotation/id"),
389388
Now, let us consider an example of calculating the frequency of reference allele, and this calculation can be done using `seqApply()` and `seqParallel()`. Let's try the uniprocessor implementation first.
390389
```{r}
391390
# calculate the frequency of reference allele,
392-
afreq <- seqApply(genofile, "genotype", FUN=function(x) mean(x==0, na.rm=TRUE),
391+
afreq <- seqApply(genofile, "genotype", FUN=function(x) mean(x==0L, na.rm=TRUE),
393392
as.is="double", margin="by.variant")
394393
length(afreq)
395394
summary(afreq)
@@ -405,7 +404,7 @@ seqParallelSetup(2)
405404
406405
# run in parallel
407406
afreq <- seqParallel(, genofile, FUN = function(f) {
408-
seqApply(f, "genotype", as.is="double", FUN=function(x) mean(x==0, na.rm=TRUE))
407+
seqApply(f, "genotype", as.is="double", FUN=function(x) mean(x==0L, na.rm=TRUE))
409408
}, split = "by.variant")
410409
411410
length(afreq)
@@ -579,7 +578,7 @@ m.sample <- local({
579578
m <- seqParallel(, genofile, FUN = function(f)
580579
{
581580
# dm[1] -- ploidy, dm[2] -- # of selected samples, dm[3] -- # of selected variants
582-
dm <- seqSummary(genofile, "genotype", verbose=FALSE)$seldim
581+
dm <- seqSummary(f, "genotype", verbose=FALSE)$seldim
583582
584583
# need a global variable (only available in the bracket of "local")
585584
n <- integer(dm[2L])
@@ -700,7 +699,7 @@ genmat <- seqParallel(, genofile, FUN = function(f)
700699
{
701700
# get the number of samples and variants
702701
# dm[1] -- ploidy, dm[2] -- # of selected samples, dm[3] -- # of selected variants
703-
dm <- seqSummary(genofile, "genotype", verbose=FALSE)$seldim
702+
dm <- seqSummary(f, "genotype", verbose=FALSE)$seldim
704703
705704
# need a global variable (only available in the bracket of "local")
706705
s <- matrix(0.0, nrow=dm[2L], ncol=dm[2L])
@@ -783,7 +782,7 @@ coeff <- seqParallel(, genofile, FUN = function(f)
783782
{
784783
# get the number of samples and variants
785784
# dm[1] -- ploidy, dm[2] -- # of selected samples, dm[3] -- # of selected variants
786-
dm <- seqSummary(genofile, "genotype", verbose=FALSE)$seldim
785+
dm <- seqSummary(f, "genotype", verbose=FALSE)$seldim
787786
788787
# need global variables (only available in the bracket)
789788
n <- integer(dm[2L])

0 commit comments

Comments
 (0)