@@ -240,8 +240,7 @@ genofile <- seqOpen("tmp.gds", readonly=FALSE)
240
240
genofile
241
241
242
242
# 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")
245
244
246
245
# display
247
246
genofile
@@ -389,7 +388,7 @@ seqApply(genofile, c(geno="genotype", id="annotation/id"),
389
388
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.
390
389
``` {r}
391
390
# 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),
393
392
as.is="double", margin="by.variant")
394
393
length(afreq)
395
394
summary(afreq)
@@ -405,7 +404,7 @@ seqParallelSetup(2)
405
404
406
405
# run in parallel
407
406
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))
409
408
}, split = "by.variant")
410
409
411
410
length(afreq)
@@ -579,7 +578,7 @@ m.sample <- local({
579
578
m <- seqParallel(, genofile, FUN = function(f)
580
579
{
581
580
# 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
583
582
584
583
# need a global variable (only available in the bracket of "local")
585
584
n <- integer(dm[2L])
@@ -700,7 +699,7 @@ genmat <- seqParallel(, genofile, FUN = function(f)
700
699
{
701
700
# get the number of samples and variants
702
701
# 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
704
703
705
704
# need a global variable (only available in the bracket of "local")
706
705
s <- matrix(0.0, nrow=dm[2L], ncol=dm[2L])
@@ -783,7 +782,7 @@ coeff <- seqParallel(, genofile, FUN = function(f)
783
782
{
784
783
# get the number of samples and variants
785
784
# 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
787
786
788
787
# need global variables (only available in the bracket)
789
788
n <- integer(dm[2L])
0 commit comments